Error handling cleaned up and error handling tests passing