Added unit test projects. Fixed bugs.