refactored utils and tests for more logical ordering