Fix for undeterministic behaviour caused by tree pointer

Contributed by Axel Naumann
Code cleanup in tests