Heal charged but dead anyway.

Several times I have spent gems to use the heal spell, been charged for the heal, it appears on screen, yet my character dies anyway. How can I cast a heal spell if dead? This is a major flaw and needs to be fixed immediately. IT really sucks to get charged gems for a heal, die and have no choice but to resurrect. It’s even worse if one is out of gems.