The head of South African athletics has apologised to the country for his mishandling of the Caster Semenya controversy , after admitting that a gender test was carried out on the teenager prior to last month 's World Championships in Berlin .