Major test restructuring and refactoring