The world's best coffee doesn't come in a white cup with a green mermaid on the side. It falls from the rear end of a cat.

Indonesian Kopi Luwak coffee, you may have heard, is a rare and exotic bean that aficionados have described as tasting "unique, mild, and smooth with a hint of dark chocolate and secondary notes of earth and musk."

"Kopi Luwak is exquisite," biotechnologist Sastia Prama Putri of Japan's Osaka University tells NPR. "I normally can't drink black coffee. I need milk and sugar. But I can drink Kopi Luwak black."

In order to extract those intricate flavors, however, the coffee berry must first pass through the digestive tract of the Asian palm civet, a small, doe-eyed toddy cat that lives in the trees. Once the fruit is inside the animal's guts, something strange and magical happens, leaving behind an enriched coffee bean that must be harvested from the creature's feces. After the undigested beans are removed from the droppings, they are cleaned, fermented, dried, roasted, and eventually sold.

The process is every bit as laborious and time-consuming as you can imagine, which is why a single cup can go for as much as $80, especially in places where demand is high, like South Korea and Japan.

The exorbitant price of Kopi Luwak also explains why a slew of counterfeiters are beginning to materialize, imparting the premium civet poop coffee market with something of a stinky reputation.

It's why Dr. Eiichiro Fukusaki, Putri, and a team of researchers are developing a first-of-its-kind chemical test to determine whether a cup of civet joe is the real deal. As the Economist explains it:

Dr. Fukusaki's quest began with many piles of civet feces, as well as undigested coffee beans from plantations in Bali, Java, and Sumatra, all of which he treated by roasting them at 205°C and then grinding them up. Instead of popping them into a percolator at this point, though, he mixed them with distilled water, methanol, and chloroform to extract the sorts of chemicals that give coffee its flavor. He then ran the extracts through a gas chromatograph and a mass spectrometer, to see what was in them. [The Economist]

The key differences between varieties of Kopi Luwak and ordinary beans turns out to be determined by a handful of chemicals: Quinic acid, caffeine, caffeic acid (which is responsible for a coffee's bitterness), and citric acid (which imparts sour, tangy flavors). As it turns out, the civet's digestive tract did little to change the compounds responsible for coffee's bitterness. Rather, the gastric juices and enzymes responsible for Kopi Luwak's weird alchemy increased the beans' citric acid twofold.

"Citric acid is highly prized in coffee," Mark Overly of Kaladi Coffee Roaster in Denver tells NPR. "It has a nice lemony quality. It brightens a cup of coffee and makes it more lively — much like with a good glass of orange juice."

Once the chemical composition of the coffee was established, the team was able to identify a specific ratio based on the coffee's citric acid concentration that would serve as a tell-tale sign of whether or not a cup of civet coffee is genuine. The chemical test, in fact, is reliable enough to point out an imposter even if 50 percent of the blend was real Kopi Luwak.

That means soon, hopefully, you'll get the beans you actually paid for. Which were once covered in you know what.