add streaming/piping functionality, update tests