Fixed and added test cases