Added test script
Made some bug fixes for queing