Add tests for the diff coverage; fix one hidden bug