Remove duplication in tests