add more tests + some micro bugfixes and optimizations