fix some state bugs
improve the demo script
rename test script to demo