refactored code, improved logging, added unit tests for helper methods, created tests directory for the test file.