Add cli test and fix cli