added a function to average the duration. Added a test for stats collector