Refactor test suite and add coverage.