GROOVY-5370: ConfigSlurper - multiple environment blocks broken

All credit for the patch and tests to Richard Rattigan (see: https://jira.codehaus.org/browse/GROOVY-5370).
 
 I just created a pull request and did some minimal refactoring.