refactor using es6 class, improve coverage