Evolution of mating types in finite populations: the precarious advantage of being rare