fixing bugs and more test scripts