I think we are talking at cross purposes a bit.
What you describe as gender is all linked to biological characteristics and predispositions, so I would count that under sex rather than gender. Meanwhile the cases of people like Hatshepsut show sufficiently that there is another category, a purely societal one independent of the biological sex. You may call that category what you will, but generally the word "gender" is being used for it. (Mind you that people did not deny Hatshepsut being a woman by sex, even if she acted as a man by gender/social role: She had a daughter that was even officially named in documents as such.)
Where it gets interesting is the sphere of behaviour, because that can be influenced both by social roles, expectations and early life experiences as well as genetical predispositions. As such both sex and gender certainly have an influence on it and it is no easy task to sort that apart due to humans being "really ing complicated" as makawa so fittingly put it.