Small refactoring. Unit tests are introduced