chunky refactoring of test controller to try and make it a bit easier to work with. Needs a lot more work- some circular references and dependencies that make it difficult to modularise further