Fix failing tests due to CTest quirk

It seems that CTest (some versions at least) on Windows reads its scripts in binary mode, such that if the script has CRLF line endings, a multi-line string will also include the `\r` characters, which can cause our output matching to wrongly fail. Work around this by adding a step to strip out any `\r`s to ensure that the expected string has the intended value.

Also remove some debugging code that was accidentally left in a previous commit.