Fixed the statistical functions
Fixed several tests of the engine