more tests and bugfixes for #796