A High Court in Kenya has ruled in favour of the legality of anal tests as proof of gay sex. Earlier in May, two Kenyan men launched a court case after claiming that police forced them to undergo an anal examination to assess their sexuality.

The two men were arrested in February 2015 on suspicion of homosexual activity, which is illegal in Kenya, and where gay people face imprisonment for up to 21 years.The pair also alleged they faced discrimination and had to take tests for HIV and hepatitis following their arrest.

However, the High Court in the coastal coastal city of Mombasa, said anal tests were permissible and added the two men did not face discrimination. Judge Mathew Emukule said there was sufficient grounds in Kenyan law for these types of examinations to gather medical evidence of a crime, including rape and sodomy, the BBC reported.

Human Rights Watch (HRW), which has been documenting the use of forced anal examinations in eight countries since 2010, said anal tests involve doctors or other medical personnel inserting their fingers, and sometimes other objects, into the anus of the accused. The rights group claimed these examinations are just humiliating and do not prove people's sexuality.

"It's frankly shocking to see such archaic methods used in Kenya in the 21th century (...) The men in the Mombasa case, and dozens of others around the world, should never have had to undergo such a humiliating and demeaning procedure, and governments should prevent this from happening to others in the future," said the group.

The Kenyan government has stated homosexuality is an "unnatural act". The country has been subjected to international pressure to amend its anti-gay laws, while NGOs warned violence against gay Kenyans is widespread.