Factor out cmd testing helpers.

For the backups CLI I'm adding the subcommands in a subpackage of cmd/juju.  For that to work, I need some of the testing helpers in cmd/juju to live in their own package.  This patch makes that happen.  This is basically a copy-and-paste patch.
It's used in several of the test files in cmd/juju.