Some primitive unit tests; other tweaking.