Re-factor analysis code and unit test.