Commandline tests

General improvement to the way the command line client is tested (see commit comments).