refactor: reuse code between stream-bundles. add tests.