module.exports = function(config, Queue, logger, idGenerator, taskQName) {
  var m = {_taskQueues: {}};

  Queue = Queue || require('../queue/queue');

  idGenerator = idGenerator || global.random;
  m._logger = logger || global.logger;

  m.createTask = function(taskName, taskDef) {
    if(!m._taskQueues[taskName]) {
      m._taskQueues[taskName] = Queue(taskName+'-queue-'+config.env);
    }
    if (!taskDef.transactionId) {
      taskDef.transactionId = idGenerator.getGUID();
    }

    taskDef = _.cloneDeep(taskDef);

    delete taskDef.rawData;
    delete taskDef.receiptHandle;
    delete taskDef.err;

    taskDef.taskName = taskName;
    taskDef.taskId = idGenerator.getGUID();
    return m._taskQueues[taskName].sendMsg({body: taskDef})
        .then(function(msgId) {
          taskDef.msgId = msgId;
          m._logger.log('CREATE_TASK_SUCCESS', taskDef);
          return taskDef;
        }).then(null, function(err) {
          var newErr = new Error('Queue inaccessible error.');
          newErr.stack = err.stack;
          newErr.inner = err;
          throw newErr;
        }).then(null, function(err) {
          taskDef.err = err;
          m._logger.logError('CREATE_TASK_FAILED', taskDef);
          throw err;
        });
  };

  m.pullNextTask = function(taskName) {
    var taskQ;
    if (taskQName) {
      if (!m._taskQueues[taskQName]) {
        log('Initializing poison queue:',taskQName+'-queue-'+config.env);
        m._taskQueues[taskQName] = Queue(taskQName+'-queue-'+config.env);
      }
      taskQ = m._taskQueues[taskQName];
    }
    else if(!m._taskQueues[taskName]) {
      log('Initializing task queue:',taskName+'-queue-'+config.env);
      m._taskQueues[taskName] = Queue(taskName+'-queue-'+config.env);
    }
    if (!taskQ) taskQ = m._taskQueues[taskName];
    debug('pulling from task queue:',taskName+'-queue-'+config.env);

    // TODO: add option and support for guaranteed FIFO, since SQS doesnt support FIFO.
    return taskQ.receiveMsg().then(function(msgs) {
      if (!msgs) {
        throw 'QUEUE_EMPTY';
      }
      m._logger.log('TASK_STARTED', msgs[0]);
      return msgs[0];
    },function(err) {
      m._logger.logError("GET_TASK_FAILED", err);
      throw err;
    });
  };

  m.completeTask = function(taskName, taskDef) {
    if(!m._taskQueues[taskName]) {
      m._taskQueues[taskName] = Queue(taskName+'-queue-'+config.env);
    }
    return m._taskQueues[taskName].deleteMsg(taskDef.receiptHandle)
      .then(function() {
        m._logger.log('TASK_COMPLETED', {transactionId: taskDef.transactionId, taskId: taskDef.taskId});
        return true;
      });
  };

  return m;
};
@@ -1256,33 +1256,25 @@
 %0A%0A  
-m.pullNextTask = function
+function getQueue
 (tas
@@ -1789,24 +1789,122 @@
 %5BtaskName%5D;%0A
+    return taskQ;%0A  %7D%0A  m.pullNextTask = function(taskName) %7B%0A    var taskQ = getQueue(taskName);%0A
     debug('p
@@ -2385,114 +2385,39 @@
     
-if(!m._taskQueues%5BtaskName%5D) %7B%0A      m._taskQueues%5BtaskName%5D = Queue(taskName+'-queue-'+config.env);%0A    %7D
+var taskQ = getQueue(taskName);
 %0A   
@@ -2424,39 +2424,21 @@
  return 
-m._
 taskQ
-ueues%5BtaskName%5D
 .deleteM

update task runner to support pulling from poison queue. Bugfix