Add tests for onFinish
Fix warnings in the test suite
Fix the tests