Added test code and error code