Several fixes for unit tests. First improvements to unit test methods.