Merge "Remove lots of code duplication in tests"