refactor __main__ to enable testing
tweak CLI