state: pass environment uuid via config rather than generate it during initialize

In order to have the uuid of the environment available _before_ state is initialised the uuid is now a part of the environment configuration.

This PR also contains some drive-by cleanups to state tests to make them more robust if they fail.
I'm not fond of the second-guessing, but I'd mind less about this being here once UUID is set by prepare