What is the evolutionary purpose of testicles?

OK, I think we can condense most of the confusion in this thread with a follow-up question:

We’ve established that sperm in some mammals do not develop properly at body temperature, but that birds with higher body temperatures are able to create sperm at their body temperature. Birds are different in many respects - they have a cloaca, for one, and I know that at least some use sperm “plugs” rather than semen. Does anyone know more about how the mechanisms are different between birds and mammals?