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 Source: Unified Global Standards (ISCED, ISCO, O*NET, ESCO)