improve error handling in tests