Added testcase for #593
In some rare cases, subtrees got invalidated and caused an assert failure