cleanup + tests

Some small cleanup in function names and comments, + some tests around the utility functions.