Also refactor util.sh in the process, so test scripts become easier to write (inspired in part by lake's test suite).