Improve coverage and fix some bug