Revised version of PR #550, which was backed out due to `grunt mochaTest` errors