cmd/jujud: fix upgrade worker error handling

If the connection to state is lost then return an error so that the machine agent will restart. For other errors, don't return the error because we want the machine agent to stay running wait for user intervention.

This change also adds tests for the handling of upgradeWorkerContext's UpgradeComplete channel. This was previously untested.
I have a slight preference for the `IsAPILostDuringUpgrade` style over the straight type assertion thing. Not sure how justifiable except for consistency's sake, and quite possibly we don't actually do that consistently in this package anyway.