If you spam /petattack your Imp will never cast firebolt because it will cancel it's current firebolt and start casting new one. If you use /cast fireball then it doesn't get interrupted so you can spam it as much as you want.

/petattack works great for MELEE pets, but not for Imps that cast ranged spell.