Add command line argument tests
Merge unclebob's unit test and related refactoring, but with some additional reformatting and refactoring.