The "Con" in both is from a Latin root meaning together.
The "test" in contest is from Latin testis, meaning "witness", from a root meaning "three" (as in, a third party).
The word test is from Latin testum meaning earthen pot, because metals could be tested for quality by melting them in such a pot.
Etymology is super interesting to me.