fix task not ending on merged streams, add tests