Fix several small race conditions.
Cleanup some tests, using config structure.