Fixed arbitrary levels of broken nesting.

And the test for arbitrary levels of broken nesting, too.

Phew!