Fix bug when orphaning a level

Only read depth when there is a parent
Write an empty dict to menu context instead of clearning it as it can't be
null
Add tests to guard against regressions to level reorganisation