add some tests + fix bugs