Fixing exit status and adding CLI tests