Debugged and added test cases