Allow nesting.
Add a couple unit tests.