The molecular and cellular basis of gonadal sex reversal in mice and humans