Heat a saucepan. Add the red chillies, coriander seeds, cumin seeds, peppercorns, and cloves. Dry-roast the ingredients for five minutes over medium-low heat until fragrant and a couple of shades darker. Remove to a plate.
In the same skillet, toast the garlic until the cloves soften a bit and have brown spots all over. Add the garlic to the plate with the rest of the spices. If you are using grated coconut, lightly brown it in the dry skillet, keeping an eye on it all the time to make sure it doesn't burn. If using coconut milk, you can add it directly to the blender.
Once the spices and garlic have cooled, add to the blender with the coconut or ½ cup of the coconut milk. Blend into a very smooth paste.
Add oil to the same saucepan. Add the chopped onions and saute, stirring frequently, until they start to turn golden-brown.
Add the sausages, if using, and saute until they start to get a crust.
Add the tamarind paste or vinegar and the ground masala paste. Stir well to mix and allow the sauce to come to a boil. Reduce to a simmer and cook for about five minutes.
Add the drained beans along with a cup of water or the bean cooking liquid. Bring the stew to a boil, then reduce heat, cover and simmer for 10 minutes for the flavors to meld together.
Garnish with cilantro and serve hot with rice or bread.