Fix usage of Popen.wait().

This is liable to deadlock if used with subprocess.PIPE and it was used like that all over the place.

I've created new wrapper that will hopefully avoid this broken usage.  This might also fix our random test stalls that have been happening on travis.