Add test and fix corner case of stats calc

Statistica were incorrectly calculated when a prefix was enlarged /
shrunk by more than one indentation level, e.g. enlarging a prefix so
that it becomes larger and covers its old parent prefix.

This adds a test for that as well as actually fixing the code.

Part of #248.