Remove duplication of end token generation in tests