More tests, more bugfixes