Refactoring: divide utility functions with doctest