QUANTUM-1 Moved code out of quantum.js

Some of the code in there makes more sense to be
in the unittest file.