Add tests for invocator main(); refactor argparsing

Argparsing was refactored to be less dependent on magic state. This
modifies tests accordingly