Added tests for error handling.

100% unit test coverage :shipit: