more tests + bug fixes