* Extracted helper functions
* Added unit test for helper functions
* Removed error logging
* Renamed some variables for better readability
* Some minor code refactoring
* Updated unit tests