Another unit test, some bugfixes as a result(!)