Refactoring: make code more readable by breaking methods into smaller ones, add more tests for new methods.