fleshing things out, added first utility function and tests for it