It works because the ghost unit of the undead was designed to never uncloak (only be revealed). It had no attack and was for scouting purposes only so there was no need for it to reveal itself ever. I think the ability cannot ever uncloak the unit. I am prety sure that in all maps where you get your units served to you by permanently invisible units that attack they are using this form of cloaking.