Fixes for numerous bugs uncovered by tests.
Fixes for numerous bugs uncovered by tests.

cnwhy/ejs,insidewarehouse/ejs,TimothyGu/ejs-tj,operatino/ejs,zensh/ejs,mmis1000/ejs-promise,tyduptyler13/ejs,kolonse/ejs,rpaterson/ejs,jtsay362/solveforall-ejs2,insidewarehouse/ejs,zensh/ejs,mde/ejs,cnwhy/ejs,kolonse/ejs,xanxiver/ejs,TimothyGu/ejs-tj