Major refactoring and normalization of test utilities.
Adds unit tests for all critical test utilities.