Fixed test script and applied some more fixes.