cmd/jujud: upgrades test refactoring

A bunch of refactoring of the tests relating to machine agent upgrades.
There shouldn't be a race because the value is checked once the upgrade-steps worker has exited (so well after the counter could be incremented).

I'm not sure a channel is the right way to go because that makes it fairly awkward to derive the count. What about having countUpgradeAttempts return a func which gives the count when called?