A bit of refactoring and cleanup
Finished tests for all utils functions