add test script. fix some things. add while loop