fixed getMochaOpts() and added tests

This is the same fix to `getMochaOpts` proposed in #54, but with tests (see the other PR for more info).