Using redid pipeline to improve the performance of api.stats

Added an unit test(core_stats.js) for api.stats