Fixed jUnit tests and bugs related to test failures.