Dear Mr. Wong:
It is just bad luck you were inspected by an officer who at that time was "on the wrong ball." It makes no difference where you are, advanced modern country, or third world nation, a person in uniform has the "authority." He can even send you for a urine test if he wants too! And there's nothing anyone can do until he is done doing what he has the "duty" to do.
I learned this the hard way - customs officers have no sense of humour! I was checking out of Singapore during my student days when the customs officer pointed at a case in my luggage for my camera's tripod stand (it was enclosed in some kind of vinyl cover and asked "What is that?" I thought the question was stupid, bloody hell! Its a tripod stand for crying out loud! Anyways, just to be funny, I answered "Machine gun" with a grin. The officer looked at me, didn't think it was funny and said, "Okay, take out everything and lay them out here!" I was ordered to pasar malam all the things in my luggage! Fuck! It wasn't funny man! After taking out everything and spreading them out for her to see, she then asked me to pack it all back, then allowed me to pass. After that incident, I just keep my mouth shut, produce my documents, and hope nothing spectacular happens. They are just doing their job.
Cheers!