Fix race conditions in defining config overrides for the tests.

The configuration overrides in the tests weren't always getting set
before the tests executed, leading to sporadic failures in the tests (as
exposed by the grunt multiTest task). This should be fixed by
re-ordering how config overrides get applied and ensuring the config
builder polling gets properly terminated at the end of each test.