Amid an uncertain political period in Kenya, LGBT activists scored a victory Thursday: an appeals court, overturning a lower court’s ruling, held that forced anal examinations of suspected gay men are unlawful.

As we reported in 2016, the shocking procedure of forced anal examinations—still practiced in at least eight countries—is useless as a diagnostic tool, but quite useful as a means to humiliate and entrap suspected gay people.

In theory, doctors examine a man’s anus to see if it has been stretched, strained or cracked, presumably a result of anal sex. In practice, the human anus just doesn’t work that way; it resumes its normal shape, either immediately or after a short period of time. You might as well test a rubber band to see if it’s ever been used.

In September 2017, The Kenya Medical Association released a statement to “condemn and discourage any form of forced examination of clients, even in the guise of discovering crimes.”

What the procedure does quite effectively, however, is humiliate suspects. To strap someone into stirrups and forcibly penetrate their anus is more like rape than medicine. Doctors can even create “evidence” of anal sex in the exam itself. It’s diagnosis, evidence, and punishment all wrapped into one.

That’s why the procedure violates the Convention against Torture, the International Covenant on Civil and Political Rights, and the African Convention on Human and Peoples’ Rights—all of which Kenya has ratified.

Still, in 2016, a court held that the need to gather evidence of a crime outweighed an individual’s rights. That decision was condemned by human rights activists at the time, and was overturned this week.

Njeri Gateru, Head of Legal Affairs at Kenya’s nonprofit National Gay and Lesbian Human Rights Commission, said in a statement that “We are thankful that the Appeal Court has put Kenyan citizens’ rights first. With this ruling, the judges are saying that we all deserve to be treated with dignity and afforded our basic rights, as enshrined in the Kenyan Constitution.”

“The humiliation and pain caused by these useless anal examinations will follow our clients for the rest of their lives,” Gateru continued. “However, we are emboldened to see our constitution at work, ensuring that all Kenyans have the right to dignity.”

The ruling comes as the High Court is considering a much more important case for LGBTQ people: a constitutional challenge to Kenya’s ban on gay sex. The Court has said that on April 26, it will announce the date for delivering its ruling.

Like many African countries, Kenya inherited the ban, and homophobia in general, from the British Empire, which occupied the area from 1895 to 1964.

Prior to European colonization, East Africa had several traditions of male priests who dressed as women and sometimes married other men. Among the Meru and Kikuyu peoples, for example, these individuals were called “mugawe.”

That all changed with the introduction of European Christianity to Kenya, and today, the country’s anti-gay law carries a penalty of 14 years in prison. It is used to prosecute roughly 100 people each year, but more importantly, it is used as a pretext for pervasive discrimination and violence.

The pending High Court case is being followed closely on all sides, and American-based Christian fundamentalists have once again meddled in Africa’s internal affairs, fanning the flames of homophobia.

For example, The American Center for Law & Justice, partly run by Donald Trump’s lawyer, Jay Sekulow, opened an affiliate in Kenya several years ago, and has campaigned virulently against LGBT people ever since.

The ruling on forced anal examinations is not expected to impact the case on the gay sex ban.

More broadly, the ruling appears at a time in which Kenya’s political system is reeling from a bitter election scarred by violence—at least 70 people were killed by police—and a contested result, with additional violence erupting, often on ethnic lines.

The president and opposition leader met recently to attempt a rapprochement, but then came new revelations that the Trump-linked firm Cambridge Analytica had also worked for the Kenyan president, hacking Kenyans’ personal data and promulgating fake news.