Add test cases for handling error