tests, bugfixes and improvements