Yeah, as you said in that thread, it can bug.
there is an object merger that vJass supports where you create your own units and abilities directly from there. That would be the approach I recommend.
As for a library to handle it, to make it bug-free, would require a dummy with 0 mana regeneration and have it cast the ability in a place where no one is around to watch, and record the mana lost.