Moved helper functions to utils module and added tests