added test case and formatted code