Modified stats functions in utils file. Added tests for the functions. Created a management command to run stats updates. Refs #63