What’s more worrying isn’t that they tested—it’s that the existence of the test feels like a smoking gun. That says more about our broken trust in institutions than anything else.
It says more about the nature of pharmaceutical manufacturing than anything. We often need to screen for impurities, and cyanide is a pretty common one.
I know some companies use spectroscopy (often raman) to scan select pills/capsules/vials to ensure there aren't any contaminants and to ensure the content is uniform throughout the pill rather than concentrated in one part.