fix errors
add tests