Doctors are testing seniors for drugs such as heroin, cocaine and “angel dust” at soaring rates, and Medicare is paying the bill.

It is a roundabout result of the war on pain-pill addiction.

Medical guidelines encourage doctors who treat pain to test their patients, to make sure they are neither abusing pills nor failing to take them, possibly to sell them.

Now, some pain doctors are making more from testing than from treating.

Spending on the tests took off after Medicare cracked down on what appeared to be abusive billing for simple urine tests. Some doctors moved on to high-tech testing methods, for which billing wasn’t limited.

They started testing for a host of different drugs—including illegal ones that few seniors ever use—and billing the federal health program for the elderly and disabled separately for each substance.

Medicare’s spending on 22 high-tech tests for drugs of abuse hit $445 million in 2012, up 1,423 percent in five years.

The program spent $14 million that year just on tests for angel dust, or PCP. Sue Brown, a laboratory director in Brunswick, Ga., said she has never seen someone over 65 test positive for angel dust, in 25 years in the business.

Click for more from The Wall Street Journal