The European Court of Justice on Thursday prohibited member nations from putting asylum seekers through tests that aim to determine their sexual orientation, BBC reported. The apex court criticised Hungarian immigration officials for making a Nigerian asylum seeker undergo a psychological test to determine if he was gay in 2015.

The tests should not be used as grounds to reject petitions for asylum, the court said in its ruling which is binding in all 28 European Union nations. The court termed the testing as an invasion of “the most intimate aspects” of life.

Homosexuality is a crime in several countries, particularly in Africa. In 2013, the European Court of Justice had ruled that member nations could provide asylum to people who risked imprisonment on grounds for homosexuality in their home country.

In 2015, the Nigerian applicant had claimed that he was being persecuted for being a homosexual in his home country while seeking asylum in the Hungarian city of Szeged, Reuters reported.