Code for average score and qunit test.