Add a unit test for MemoryQueue + fix totalTasks stat