Increase test coverage of CLI and make the tests more general