Refactoring and unit testing example