More unit tests. Some minor fixes.