rework OutputStreamData helper class, and test it as well
The main reason for this update is that we had duplicate copies of histograms in our output file, which doubled the size of histogram files and meant that user doing a simple loop over all objects in the output file would process histograms twice.
In order to make the whole mechanism more robust and testable I moved
all the output stream related code into the class OutputStreamData
and
reworked that so that it looks and behaves like a real class, with
information hiding, etc. And I added unit tests that made sure that
output objects indeed make it into the output file and only get added
exactly once to that output file, plus make sure that all the special logic
and handling indeed works properly.