Change internal working of diffusion engine, add test