More tests; some bugfixes