Improve cli tests, fs.exists should be checked after writing the file.

This should fix the failure on travic-ci.