add phpunit test for cli output and fixed a bug