corrected and added test cases