much improved test script -- thanks defunctzombie