This is complex stuff, is it covered by unit-tests? The existing three test files does not seem to cover all different branches/cases. The same comment applies to other methods below.

I'd like to see a suite of pure unit-tests where this class is tested in isolation and where all different cases are covered.