In a country where gay sex is punishable by up to 14 years in prison and where attacks on the LGBT community occur frequently, a solitary rainbow flag flapping in the wind just a stone's throw from the president's official residence in Nairobi serves as a small but symbolic mark of rebellion.

Inside the building flying the flag, one of Kenya's leading LGBT rights organizations, the National Gay and Lesbian Human Rights Commission (NGLHRC), is working on a case currently filed in the country's high court that could remove criminal punishment for adults who engage in homosexual activity altogether.

"Those laws degrade the inherent dignity of affected individuals by outlawing their most private and intimate means of self-expression," the petition states.

It is the first time that anyone has directly challenged the ban, with lawyer and NGLHRC leader Eric Gitari saying he closed the office after filing the case over fears of a backlash from members of the public, but returned ten days later to find no threats or violence had taken place.

"We wanted to monitor the public reaction, and not put our staff at risk, but the reaction has not been as expected. We thought there would be backlash but there has been none," he said.

The news barely made headlines in local media, and the social media reaction has been negligible. Next month, proceedings in the High Court will begin, though the appeals process means it could take up to five years for an outcome.

Kenya is one of 34 African nations where homosexual activity is illegal, with some countries punishing it with life imprisonment or even death. But Gitari hopes his country could soon follow in the footsteps of Mozambique and São Tomé and Príncipe, which have decriminalized homosexuality in recent years.

The case brought by NGLHRC revolves around a challenge to Section 162 of Kenya's penal code — a piece of legislation introduced in the 19th century during British colonial rule in East Africa. Under the heading "unnatural offenses," it condemns anyone who has "carnal knowledge of any person against the order of nature."

According to the Kenyan government, 595 cases were prosecuted under Section 162 between 2010 and 2014, though Gitari and his team found that most of them were cases of bestiality and rape — crimes currently seen as comparable to consensual gay sex in the eyes of the law.

In reality, Gitari says, the law is rarely enforced against homosexual activity, with only one person convicted since 2011. But activists say the law still provides legitimacy to discrimination in a society in which 90 percent of people oppose homosexuality, according to a 2013 survey by the Pew Research Center.

Gitari himself was outed as one of Kenya's "top gays" on the front cover of a national newspaper in 2015, while in February last year two of his clients were subjected to anal examinations and HIV tests at the hands of police, after being accused of homosexual activity under Section 162.

It was the first case of forced anal testing that Gitari had heard of, but he knows of other cases in which men have been saved from the humiliating procedure at the last minute after doctors refused to carry it out. Meanwhile, the media attention surrounding the case resulted in mob attacks on suspected gay men in some parts of the country, forcing dozens of people from the LGBT community to flee their homes.

This week a court heard a petition from the two men challenging the use of anal exams, the outcome of which is expected in the coming months.

It was also due to Section 162 that Gitari's application to officially register the NGLHRC as an NGO was rejected in 2013 on the basis he was seeking to promote illegal behavior. The High Court overruled the decision, but government regulator the NGO Coordination Board then appealed — a challenge Gitari is still battling against.

But the registration process has already yielded one victory, after the High Court ruled that someone's sexual orientation was protected under the constitution — meaning the right to privacy, dignity, and equality that appear in the constitution's bill of rights could not be limited to people of a particular sexual orientation.

Nevertheless, the ongoing criminalization of homosexuality leaves LGBT people ostracized and vulnerable to violence and blackmail.

"Young men have sex with older men for financial gain, and then cry rape if they don't get the money they demand," Gitari says. "We provide legal aid for so many blackmail cases like this. When people can't get intimacy they will do things that are not safe."

Meanwhile, on top of the danger from homophobic attacks, Gitari says the ongoing illegality of homosexuality contributes to an ongoing problem Kenya's LGBT community has with suicide. Gitari says he knows numerous people who have committed suicide, and even considered it himself.

"It is something that everyone who is gay goes through in this country. I thought about killing myself when I was young," he said. "That hopelessness, without anywhere where people can meet, that's what's killing people and the source of that is the law."

According to Gitari, the country's capital city provides something of a welcome haven of greater acceptance to the LGBT community — although problems persist even there.

"Nairobi allows us to be anonymous. Everyone minds their own business," he says. "There have been cases of rape and violence and physical assault, but the fact that it is not systematic widespread shows it is not comparable to our neighbors, like Uganda."

It was in Nairobi that a pro-gay music video was filmed earlier this year, a remix of Macklemore's 2012 hit Same Love.

When it appeared on YouTube, the Kenya Film Classification Board (KFCB) tried to make Google take it down, with KFCB Chief Executive Ezekiel Mutua claiming the content threatened to turn people into "Sodom and Gomorrah." While Google refused to remove the video, it agreed to post a warning for Kenyan viewers flagging it as "potentially inappropriate." The makers of the video added a line to its description warning "This video contains imagery and a message that may be unnecessarily offensive to some."

But in tweeting its outrage, along with a link to the offending video, the KFCB inadvertently gave it a massive boost, helping to take the video from a couple of hundred views to over a quarter of a million.

KENYA: Film Classification Board bans 'Same Love' video featuring gay Kenyans saying it 'promotes' homosexuality https://t.co/ulK5o2OiCr

— DENISNZIOKA (@DenisNzioka) February 23, 2016

While the song has been upheld as a success for the gay rights movement in Kenya, reactionary comments on the YouTube page indicate the battle still has a long way to go.

The abuse also made its way to one of the actors who starred in the video, who has not come out to his family and friends, and says he was inundated with abusive messages and threats of violence on his phone and social media.

"I blocked the numbers and changed my privacy settings. They were really disturbing me," he told VICE News, requesting to remain anonymous. "Sometimes I do fear walking around. I'm pretty scared."

But Gitari believes that if the law is changed, societal attitudes will follow, and he thinks the political will is there — though as recent homophobic comments from Deputy President William Ruto highlighted, staunch opposition to change also remains.

"The law is a big shackle. By removing it people will understand homosexuals are not criminals," he said, adding that the government is extremely keen to promote Kenya as a good place for business and studies have shown that homosexuality laws act as a barrier.

"There is a lot of political will. We have seen consistency by the political class to refrain from legal matters when it comes to human rights," he said.

That will has already been demonstrated through the country's courts, following the landmark decision in 2014 to allow Kenyan transgender rights activist Audrey Mbugua to change her gender on her school records.

"Kenya could be a regional leader in gay rights, it's an exciting time" said Gitari.

Neela Ghoshal, LGBT researcher at Human Rights Watch, agrees that Kenya could be on the brink of taking a major step that would reverberate through the continent, with gay sex punishable by life in prison in the likes of Uganda, Zambia, and Sierra Leone, and carrying a death sentence in Sudan, Mauritania, and northern Nigeria.

Currently South Africa is the only major African economy to have made serious progress on the issue of LGBT rights, after becoming the fifth country in the world and first in the Southern Hemisphere to legalize same-sex marriage in 2006.

"There is a real sense of momentum," said Ghoshal of the legal challenge lodged by NGLHRC. "Other countries are certainly watching this court case."

But Ghoshal warned that the path would not be smooth. "Ultimately, Kenya is a political beast, and progress can sometimes be derailed in the wink of an eye."