I actually saw something about this recently, maybe on Surrender@20. Because of programming intricacies (like, how much HP should you have if you refund a Warmog's—I know it sounds stupid, but I'm not a dev either), when you buy something the system notes your current/max HP, mana, etc. If you refund something (@Daedalus871 this answers your bit) it reverts to those values.
The moment you change state (e.g. stealth, Karthus ults, etc), the system disables undo. The reasoning behind it is, what if e.g. you recall with only a couple hundred HP, see Karthus ulting, buy a Warmog's or a Zhonya's, survive, then refund it. Clearly unfair, right? So they solve it by disabling undo after you do anything.
That's not to say it's perfect; it would seem that for Teemo they probably should work around that. But hopefully you understand the "why" a bit better.