added tests, refactored cmdline entry