Updated error messages and added test cases