Add unittests for stats API