improving hanging test and tidy up on the Queue API to couple with flush timeout externally