Simplify logic in TestCheckErrors.