test: refactor utils tests to use mocked functions and improve clarity