Proper roasting, which reduces this risk of bacteria. Chemical reactions occur when cocoa beans are roasted and proper roasting is integral to good flavoured chocolate.
DATA SOURCED FROM ESCO (EUROPEAN COMMISSION) & O*NET (U.S. DEPARTMENT OF LABOR)