extract code to indexutils.js for test and product env