/stopcasting is worthless after a GCD spell. /petattack won't work like you want it. Pet won't be active when /petattack will be issued. So you have to press the button twice.
/petattack
/cast Shadowfiend
or (because switching pet stances resets their aggro/target, so telling pet to attack then moving it to aggressive will just make it go to nearest target afaik

)
/petaggressive
/petattack
/cast Shadowfiend
(not sure about stopcasting and petattack petaggresive)