Added unit-tests and analysis functions.