Move internal test helpers to the test module to clean up the public API and add support for escaping common whitespace characters in output values.