test script + some refinements