Improved the logic in UIScope, and also UITestBase. Closes #54 and #64