diff --git a/include/ajax.draft.php b/include/ajax.draft.php
index 5f36b4704a78c35ff032fa363b23a93dbbcf3a3b..9fa61635d730f8e1a67a4ebe18ea35271bf7eee0 100644
--- a/include/ajax.draft.php
+++ b/include/ajax.draft.php
@@ -96,7 +96,7 @@ class DraftAjaxAPI extends AjaxController {
 
             // Paste uploads in Chrome will have a name of 'blob'
             if ($file[0]['name'] == 'blob')
-                $file[0]['name'] = 'screenshot-'.Misc::randcode(4);
+                $file[0]['name'] = 'screenshot-'.Misc::randCode(4);
 
             if (isset($file[0]['tmp_name'])) {
               $ids = $draft->attachments->upload($file);
diff --git a/include/class.forms.php b/include/class.forms.php
index d78f8f66c74062974847dc5b9af110e28f5977b5..4a0f2f72efd4ce4d271dba003c24816f87e724f4 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -430,7 +430,7 @@ class FormField {
         return $this->_errors;
     }
     function addError($message, $index=false) {
-        if ($field)
+        if ($index)
             $this->_errors[$index] = $message;
         else
             $this->_errors[] = $message;
@@ -2758,7 +2758,7 @@ class ChoicesWidget extends Widget {
                 echo $def_val; ?> &mdash;</option>
 <?php
         }
-        $this->emitChoices($choices, $values); ?>
+        $this->emitChoices($choices, $values, $have_def, $def_key); ?>
         </select>
         <?php
         if ($config['multiselect']) {
@@ -2773,10 +2773,10 @@ class ChoicesWidget extends Widget {
         }
     }
 
-    function emitChoices($choices, $values=array()) {
+    function emitChoices($choices, $values=array(), $have_def=false, $def_key=null) {
         reset($choices);
         if (is_array(current($choices)) || current($choices) instanceof Traversable)
-            return $this->emitComplexChoices($choices, $values);
+            return $this->emitComplexChoices($choices, $values, $have_def, $def_key);
 
         foreach ($choices as $key => $name) {
             if (!$have_def && $key == $def_key)
@@ -2788,7 +2788,7 @@ class ChoicesWidget extends Widget {
         }
     }
 
-    function emitComplexChoices($choices, $values=array()) {
+    function emitComplexChoices($choices, $values=array(), $have_def=false, $def_key=null) {
         foreach ($choices as $label => $group) { ?>
             <optgroup label="<?php echo $label; ?>"><?php
             foreach ($group as $key => $name) {
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 94389a5e827077130f51774c6840c1050b0fbe34..9198bf4b4cc3fdab010dd3d718316a020554916f 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1836,7 +1836,7 @@ implements RestrictedAccess, Threadable, TemplateVariable {
                     return new FormattedDate($this->getCloseDate());
                 break;
             case 'last_update':
-                return new FormattedDate($upd);
+                return new FormattedDate($this->last_update);
             case 'user':
                 return $this->getOwner();
             default:
diff --git a/include/class.user.php b/include/class.user.php
index 960588dae4853e7a8f1952b7c4ac4d3885450104..1b4e309d8af92aae4aef4e277ae23df2c0ffb894 100644
--- a/include/class.user.php
+++ b/include/class.user.php
@@ -685,7 +685,7 @@ implements TemplateVariable {
         if (!($mails = Mail_RFC822::parseAddressList($this->address)) || PEAR::isError($mails))
             return '';
 
-        if (!$list && count($mails) > 1)
+        if (count($mails) > 1)
             return '';
 
         $info = $mails[0];
diff --git a/setup/test/run-tests.php b/setup/test/run-tests.php
index f42c121d7e48b345bf6407b2cde0ea25dc2454c3..30d81e225735c50e21d2634cae790d00b22d1d4f 100644
--- a/setup/test/run-tests.php
+++ b/setup/test/run-tests.php
@@ -8,6 +8,7 @@ $selected_test = (isset($argv[1])) ? $argv[1] : false;
 require_once 'bootstrap.php';
 require_once "tests/class.test.php";
 
+$root = get_osticket_root_path();
 $fails = array();
 
 require_once INCLUDE_DIR . 'class.i18n.php';
diff --git a/setup/test/tests/stubs.php b/setup/test/tests/stubs.php
index 620f763a55090b6bb423e2b36a6b378f44255a8e..24670dbdea13641aa632e59d82231af895c4c611 100644
--- a/setup/test/tests/stubs.php
+++ b/setup/test/tests/stubs.php
@@ -37,6 +37,7 @@ class mysqli_result {
 class ReflectionClass {
     function getMethods() {}
     function getConstants() {}
+    function newInstanceArgs() {}
 }
 
 class DomNode {