Improve code coverage and add more negative tests.