Fix discrepancy between code for error messages and their tests