improved error handling in test