Moved functions from hep-ce_utils to stats header. Added some tests.