Add unit tests for util functions
util should be self-contained, so they should get unit tests. These should maybe written as doc tests, and doc tests be enabled in tox/CI.
The goal of this issue is to write tests for all util functions in existence at the time of resolving it. After doing so, new merge requests that add or change util functions will be required to contain tests.