Add tests for error cases