Latin testis (witness), possibly from ter-stis, the one standing as third between two disputants. Testify, testimony, testament, contest, protest, and detest all descend from it: legal language built entirely on the standing third. The testicle connection is folk etymology; testiculus is a diminutive of testis in a different sense, witness to manhood, and the oath-gripping story is unattested in any classical source.
The tale that will not die: Abraham's servant placing his hand under the thigh in Genesis, inflated into a Roman courtroom practice, repeated by lecturers who never checked. It survives because it is vivid, masculine, and sounds like something Rome would do.
The kernel beneath the myth: testis as witness and testiculus as anatomical term genuinely are the same word at root, Latin itself made the joke, the parts that testify. The false story is an embroidery on a true pun the Romans already owned.
Why do the false etymologies always travel further than the true ones?