Test error handling