Refactoring. Extract scopes.
Cover scopes with tests.