Added some code to test script and emulater