your RX medications are none of TSAs business at all. Them pawing through your medications is beyond there limited scope. Questioning is way out of line and you should be calling for a LEO to put a end to "search" as it has violated the terms of a administrative search as well as the 4th amendment.
The expiration dates that the manufactures impose or that the pharmacy puts on are just recommendations, its pretty much a CYA for the manufacture as well as a gotcha for them to make more money. Even after that date passes they are still good, most pills will still have a majority of there potency and effectiveness for years after there "expiration date". Only caveat to that is medications that require refrigeration as if they aren't stored properly or have a much shorter life span if not stored at the right temperature. I have pain killers at home that "expired 5 years ago" that work just like the ones in a RX i got last week.
Bocastephen - there are some limitations to the last part of your statement about names on bottles, and can cause some sticky issues with LE if noticed till everything is sorted out.
Personally when i travel with medications they are at the very bottom and the whole bag is secured with locks (combo). I do this because i have medications that on the street have a very high value, beyond the abuse/addiction factors. Yes I have RXs for all of them and are something anyone who has to deal with a back injuries or major orthopedic injuries.
If TSA decides to bag check it I tell them they do not have permission to open the bag until a LEO is present to witness the "Search". This normally sends them into a power trip where a the famous terroristic threat has been tossed in my direction. It generally goes down hill from there fast, where normally i have to read them the riot act unless they want mess with multiple federal agencies as well as federal Statues and USC they best back off. *
In the rare chance that a clerk doesn't blow themselves up to power trip and there agreeable and ask why, I will tell them its due to attempted theft by TSA employees in the past and that at this point i don't trust anyone who work for TSA at all and I ask for a LEO to be present to cut down on the risk of theft.
*=Trust me i have witnessed the DEA in action, you dont want to even go there as its not pretty as they make a ATF weapons search look like a walk in the park and pleasant.