Refactored code to determine containerless statement nesting before evaluation.

Also updated test.