Only teardown once set up has finished successfully.

OK, going through the rest of the code for this helper... as I understand it, the `setImmediate` and this flush all callbacks loop are to support a queue of states which get executed in some kind of order.  The state changes may be either promise-based (new) or function-based (backwards compatible) - is that correct?

`setup()` and `teardown()` both work via `run()`.  `run()` returns `result === undefined || !!result.then ? result : undefined`; so the logic goes something like:
 - If there is an old-style state change function run, which doesn't return anything, result === undefined and so "true" is left in the callback list
 - If there is an old-style state change function run, which does return something, result !== undefined, so it checks for `!!result.then`, triggering an error on non-objects?  If that doesn't error, `.then` is likely undefined, so it returns undefined.
 - If a promise is run, it'll be added to the list.

This would give you an initial callbacks list filled with (probably) a mix of `true`s and promises.  This is passed into Promise.all for execution.

*Then* the list is filtered, removing all the non-undefined results.  So that'll leave the mix of `true`s and other stuff that's been returned from the existing functions, as well as any new promises added asynchronously in the meantime... right?  I think that'll work, just in a slightly weird accumulating-non-promises way.

The known teardowns are run, then any known setups, and then any known teardowns, etc.  I think - unless I've got all of this wrong - that still doesn't protect individual modules from having teardowns and setups run out of order.  Because all of this is executed in a setImmediate, and it's working through a queue, I think a module could be set up and torn down while other stuff is still processing a setup.  This code will then run `processStateChanges` again, which will run all of the teardowns, and then all of the setups - so maybe errors in the teardown, and then leaks on never-torn-down stuff after the setup...