It seems that the priestly classes are the ones who benefit from nationalized religions, so I cannot agree with your statement. I do not see them as group survival strategies but rather hedonistic territorial tendencies given lots of power and no responsibility.
There exist groups within groups. Like your example Priest, or Police. Depends on the group the individual identifies with. There are moral codes within these groups which support the smaller group which the individual identifies with but is detrimental to the larger group. The larger group will try to enforce it's values on the smaller group. It really depends on which group has a stronger identification for the individual. The smallest group being the self. For some the self provides the strongest identity. For others family, others religion or nation. Some humanity as a whole. This is cultural or learned or perhaps even genetic in the case of the sociopath.
Sometimes moral codes are fashioned in reaction to horrors and abuses, and horrors and abuses sometimes are justified as beneficial to the group. I think transcending this is a virtuous goal, and the question becomes how to have moral codes which are not merely about the survival of the group and how we got the ones we have.
I suspect if you could identify the group the individual has the strongest identity for it'd be pretty easy to understand the justification for their morals. If you identify more with humanity as a whole, these horrors/abuses are detrimental to humanity. There the folks who commit these acts. The victim is excluded from their group. Whatever the group is, even if it is the individual themselves. Folks do this mental exclusion so the morals of the group do not extend to the victim. The action is justified because the individual is not a member of the group the perpetrator identifies with.
There are various thought-models we can have to try and explain History, but we still need to take actual historical events into account to verify or deny those thought-models so we can know what is going on.
Certainly this is at most a personal theory.
Group survival is a good concept and a useful one to consider. It doesn't always appeal to individuals, to legislators and to governors.
The size of the group is scalable. Republicans vs Democrats. Americans vs Russians. Family vs community. Individual vs government.
Rationally, the larger the group where the group in return, supports the individual, the better the individual's chance of survival. However, humans are not always rational.
Morals which support yourself only are not as rational as those which support the family. Morals which support only the family and exclude the community are not as rational as those which support the community.
Religious morals support the religious group even sometimes at the expense of the individual. People outside the religious group, the morals don't apply too. This is why I suspect the Bible is seemly both supportive and barbaric. Christians go to heaven, non-Christian go to hell. Whereas Christians who identify with the larger of all of humanity find a way to invalidate the concept of hell.