Bugfixes and additional test case.