refactor tests.
Add support for passing in argv.

Useful when calling as a sub-script.