Hello, I ran in to the same issue where set_contact_alias were applied in some cases and in some cases not. I nailed it down to be related to having GRUU support enabled in the registrar.
Originally I had the configuration: modparam("registrar", "gruu_enabled", 1)
Disabling GRUU made it work as I expected: modparam("registrar", "gruu_enabled", 0)
This may be expected behaviour but in my case I tried to figure out why it in some cases did apply the alias and in other cases not. Maybe this will save someone else a few hours of confusion and frustration...