I use this macro to be intelligent and cast the appropriate spell based on my target.
#showtooltip
/cast [harm] Wrath;
/cast [help] Regrowth;
/cast [@player] Regrowth;
Problem A:
When: I have an enemy targeted, I spam this macro to cast Wraths.
Then: Sometimes it casts regrowth. Sometimes it casts Wrath.
Problem B:
When: The macro erroneously casts regrowth instead of wrath
Then: I do not get removed from Moonkin form on cast.
Other Notes:
When: I have myself targeted, I use the macro to cast Regrowth on myself.
Then: It always casts Regrowth. It always takes me out of Moonkin form.