Add some more tests and fix some issues.