Minor fixes.
Add tests.