Hi Empact.
Thank you for the feedback, but I prefer to keep modifications to a minimum. Apart from this, I am a newbie with this code and not really proficient with C/C++, which is actually why I am focusing on unit testing in the first place. Functions added are either read only or do not modify the runtime data. That is why I did this in the first place.
First priority here is to dig out the contract and make it testable the way it is now. I consider this as a prerequisite for any subsequent changes.
If you have any hints, then please be more explicit, as I partly understand your approach, but do not really know how to implement it in a safe manner.