Yes, he's "stall sour" and wants to go back where there are other horses, peace, and food. Horses believe that those 3 items make an area 'familiar and safe'. He's likely doing this because of the new surroundings. Yes, in one perspective, he's both anxious and 'testing' you to see if you will permit him to go back where he wants to go. What it means is you need to reconnect with him and show him that 1) work means work, and 2) he's not alone! When they're anxious, horses sometimes forget that they're in a partnership with you, and you need to take up your leadership role again. The first thing to realize is that when your horse is experiencing anxiety, it's not a time to go 'aww poor baby'. That's how humans deal with anxiety, not horses. You need to be present, accounted for, and his leader. It's a time to be a confident leader, so that your horse becomes confident in himself and knows he's with you, he's not alone. 'Pushing him around' a little bit makes you the herd mare, and asserts you as such. Your horse needs to turn to you for answers, not take it upon himself to get worried and find a comfortable place to go.
(There was another Schiller video I can't find about horses being 'barn' sour, or just preferential to some location, but these were the essentials:)
1) If he does it while in ground work: note the place he wants to stand and go back to his stall, and lunge him in that place. Make him do really hard work, like quick transitions and backing up. Make him pay attention to you. After you've worked him in that spot for a few minutes, take him to the place he "didn't want to be" and let him stand there. By doing so, you turn his least favorite place to stand into a loafing area where he can rest. Then he will like it!
2) If you're riding and he speeds up at a gate, make him work next to the gate. Hard work means tight circles, backing up, transitions, etc. You have to teach him that the gate is nothing to get excited over - it, too, means work, not food.
If you really want to be adventurous, you can even keep his halter on while he's in the stall and have him do some small in-hand work there. You can have him exit and enter the stall, back up, turn a tight circle, and then lead him back to the arena and give him a cookie. =) Let me know how it goes, and good luck!