Fix crashes when non-streaming jars are used

This includes #637 (thanks @ap-ensighten). In addition this PR adds tests and handles the scenario where steps with non streaming jars and streaming jars are interleaved with each other.