Added class error handling and more test cases