reworked State.NewEnvironment()

state: NewEnvironment now provides an initialized environment
    
NewEnvironment used to just add an entry to the environments collection. Now all required initialisation is performed so that the returned environment is ready to use. This has required a signficant change to the the method's signature.

---

state: extracted environment setup ops
    
The code to generated DB operations for setting up the initial environment have been extracted so that they can also be called from elsewhere.