add some tests + fix bugs
add some tests + fix bugs