fixed unit tests, bug fixes