I am not sure why it isnt working, I assume it is because even if you prevent the death of the entity, its hp is still 0.. sth like that.
BUT there is another way you can use, actually this is how I prevent my entities from diing.
Use the event that is called when an entity is taking damage (LivingHurt ? I am not sure..) In that event check if the damage is killing the target, damage>hp and if it does check if the player has the immortality effect..