Test: Improved CLI testing infrastructure

Added a LoggingTerminal class to the infrastructure, which can be used
in tests, to make sure that CLI commands write out the right data