Refactor jestreams and unit test