implement pipe_to_string() and use it to shorten the test case sourcecode