Move helper function from test_cli to helpers