Two men found with cocaine and heroin have been slapped with a fine – and avoided jail.