Fixed various issues during unit testing. Unit test is done.