more unit tests and fixes.