Clean up and some testing stuff

Code clean up and first steps toward fixing the test suite for the
`seach` command.