Use platform-specific newlines when verifying error messages

A few tests were failing on a clean checkout on Windows due to comparing platform-specific newlines from the production code against Unix-style newlines in the test code. I've fixed this by using `String.format` with the `%n` format specifier. This is consistent with other existing tests.