Added functions to analysis.js and unit tests.