Env refactoring

Hi there,

I'm working on refactoring bits and pieces of the Env module trying to have more solid unit tests and less complexity.

The long term goals would be to have a clean infrastructure here to allow easier support for editors, and if it works out, moving from file system to NPM for generators detection.

I'm not super comfortable with the actual code to do these changes without risking to break something. So I'm starting here and there to simplify, extract and add a solid unit test base.

I'm not sure if this should be merge as it goes or waiting to merge a big chunk. As you feels!