Adds better error handling in tests