Fix bug with env#run implementation

Refactor and add tests around env#run implementation.

While doing this, I falled on a bug with env#error returning Self, and
this was misleading other part of the application in thinking no error had
been thrown when an error listener was set. Now env#error returns the
provided error for more consistency and to allow error handling.