Also, since your button is created as a secure frame, you
can't use :Show() and :Hide() on it while you're in combat. If you want a unit frame, create a secure unit button (as you're already doing) and use RegisterUnitWatch on it like Dridzt said; you don't even need to use a state driver to hide/show it, as the UI will do that automatically based on the existence of the unit it's registered to watch.
The example code on Wowpedia is really messy, so here is a cleaner one:
Code:
local f = CreateFrame("Button", "MyPetButton", UIParent, "SecureUnitButtonTemplate")
f:SetAttribute("unit", "pet")
RegisterUnitWatch(f)