Tidy up stream test harness & fix race conditions

Should sort out travis failures caused by #336