A refactoring to optimize code.
Add unit tests.