I just now noticed that when a unit that starts with a religion in its xml defines but had converted to a different religion, it reverts back to its original religion once it turns barbarian. This isn't exactly a bug, but it does seems odd to me and has caused quite a bit of confusion for at least one player of my modmod.
I looked into this and I think the oddness comes from letting units with an XML-assigned religion convert to a different religion in the first place. Units who have a religion set in XML are things such as Priests and Religious-specific units and heroes (who also all have the <PrereqReligion> tag as well).
I suggest that you alter your code so that units with a religion set in XML arent allowed to change religions.