add checkEnum
add tests, fix bug
refactor