bugfixes & test script