Fix Error handling for generator

A generator raising an exception will now correctly emit an `error` event.
This can be used in unit test as the error event is now binded between the generator and its run context. 
i have to keep the `if` because we are either in the `process` case, either in the `process.domain` case. As we are changing the error handling for both (because we don't know if the tests are running through `mocha` command or `gulp mocha`), one of them is undefined depending on the case.