more unit tests, and related improvements