Improve tests and code coverage