Kenyan officials have come under fire from LGBT activists in the country over a case where authorities allegedly forced two men to undergo HIV and anal testing to verify whether or not they were gay — considered a crime in Kenya that can land someone in jail for up to 14 years.

The Nairobi-based National Gay and Lesbian Human Rights Commission (NGLHC) filed a lawsuit this week against a judge and police station in the small coastal town of Msambweni, claiming the officials ordered the testing during an ongoing trial against the defendants who face charges under the country's anti-gay laws including "unnatural offenses" and trafficking "obscene material."

Human rights lawyer and NGLHC head Eric Gitari said doctors at the Coast General Hospital in Mombasa took the individuals' blood while they were in police custody, testing for HIV and Hepatitis B. The healthcare workers then reportedly made the men raise their legs in the air while they performed an anal exam.

The men's trial is on hold until later this month, with Gitari filing the lawsuit to halt it from moving forward. According to him the procedures violate the constitutional rights of the men, whose identities have been withheld.

"We're asking the courts to declare the entire case annulled and give compensation to the petitioners who [were] subjected to degrading treatment by the state," Gitari said. "We want that precedent stopped... They're treating homosexuality like a disease right now."

The controversy started earlier this year after pornographic images circulated in social media believed to be featuring men from the coastal community, sparking public backlash against gay men and transgender women. Following the incident, the community also began to put pressure on authorities to prosecute and crackdown on LGBT individuals.

Meanwhile there were physical attacks on gay individuals, an atmosphere that pushed many members of the community to flee in fear, according to a Human Rights Watch (HRW) report on LGBT attacks on Kenya's coast that came out in September.

'The fact that this happened and could happen again is very threatening to people's freedoms'

In the midst of the controversy, on the morning of February 18, police arrested two young men at a restaurant in Msambweni, Kwale County. Following the arrest, police had the magistrate approve a court order for medical testing. The men were then transported to the government hospital where the medical procedures and testing were inconclusive, but the men were still slapped with same-sex relations related charges.

The pair was eventually let out on bail and Gitari said they are hoping to have their suit heard in Mombasa's high court before the trial picks back up again in mid-November.

While homosexuality is illegal in Kenya, these types of charges rarely make their way to court and not a single case has been fully prosecuted. More commonly, however, police use these anti-gay laws to harass or extort members of the community.

"We don't know of anybody who has been convicted," said Leslie Lefkow, the deputy director of HRW's Africa division, explaining, however, that "the law makes LGBT people vulnerable and essentially deprives them of recourse."

According to the HRW report, this case of anal testing in Kwale is there first reported instance in Kenya. The organization noted that it is a common practice in countries like Egypt, Uganda, and Cameroon.

But while this anal exam case may be unique in Kenya, and likely perpetuated by the anti-LGBT sentiments that were looming along the coast at the time, Lefkow said it was crucial for the courts to side favorably with the constitutional challenge to prevent this tactic from becoming more prevalent.

"The fact that this happened and could happen again is very threatening to people's freedoms," Lefkow said. "That is a path that we don't want Kenya to go down... At a very basic level, the courts need to shut down the use of anal exams."