wrote test script, + some fixes