Horses are like kids. They will always regularly test you even if you correct them and there will be days when they are worst than others. They are mammals like we are. Different things will affect them on that day that will change their behavior.
What you did was a correct way to respond but I would have probably also smacked him in the chest with my hand and give him another firm no. Stopping him and back him up and start over and keep repeating that until you finish tacking him up.
My rule of thumb when horses are being silly like that is that, if they have the energy to misbehave, then they will have the energy to go on the lunge line and do some work on the lunge line. It's my non-aggressive way of making them realize that if they choose to misbehave, then it's actually going to be a lot more work than if they just listen. Horses spend 24 hours in a day out to pasture so I think they can devote me 1 hour out of their day to work.
Also make sure that his behavior is not related to pain or fear from something that is happening at that moment or from a past experience.