wrap command's output instead of expector's input

This is a bit more reliable.

Also fix an apparent race (caught by -race) around the expector's input stream
closing. Switched to using vanilla pipes and closing the other end instead.