Helpers for working with stdin and stdout in tests