Extracted functions to src/utils + added unit testing