Fixed bug in queue_dequeue and added relative test.