Haven't had this happen to me in Thailand, but as always, wise to keep eyes open, and make mental tally of bill in your head before you hit the cash register. My worst experiences with Serial Bill Padders has been at European restaurants located on famous city squares.
OP, well-handled, I must say. In your place and after getting my correct change back, I probably would have turned into a harpy and scratched the cashier's eyes out, along with a torrent of verbal abuse.