TestHandler: better error handling