Fixing bug in q calculation
Updating test script