add some tests and bugfixes