Remove some duplication in tests