Fix a few issues

* Set coverage env variables before mocha requires
* Ensure output buffer has finished writing before calling `async()`