Improve test coverage
and fix found errors.