maybe it was unclear in the beginning if npcs can have a race.
and it uses UNIT_FIELD_BYTES_1(0), so it is with some reason on unit-level.
About this patch.
I see no other way then to use the way sd2 handles this (by display-id) - which could be ported to mangos-code.
This would actually be nicer as it would then be a script-effect. But move something rather ugly to mangos.
Hence I think the ugly code is better left in sd2 even if it must be considered a hack there