refactoring for test_cli