Improve code coverage and fix quality flaws