tests for command-building

also shuffle utility functions around