hmm.
you are right about the healing part, that should not happen.
cant it be done like this? very pseudo code

base_hp = 100;
boost_hp = 200;
hp_while_boosted = base_hp+boost_hp;
on_damage {
boost_hp = boost_hp - damage;
current_hp = base_hp+boost_hp;
}
on_loose_boost {
if (boost_hp < 0) {
current_hp = base_hp+boost_hp;
} else {
current_hp = base_hp;
}
}
hope its clear what i mean.
just make the unit loose the boosted hp first in combat. if the boost effect is gone and the boost_hp still was above 0, reset hp back to base_hp. if the boost_hp got negative (received more damage than boosted) reduce base_hp by the difference between boost_hp and 0.
would mean:
start at 100 hp. be boosted to 200. receive 180 damage; loose buff = 20 hp of boost remain, they are lost; back at 100 base hp.
start at 100 hp, be boosted to 200. receive 250 damage; loose buff = damage received was 50 higher than boost received; reduce base hp by 50.
if MG 'remembers' the hp before boost one could not abuse it for healing too.
hope my pseudo code and explanation is able to communicate what i want to say
