Tweak code, add test script