[PATCH] test: Better handling of stdout and stderr