add tests for error handling