Encapsulate JS classes / methods in 'RJR' namespace

Also slight refactoring to use standard js prototype
based inheritance. Tests updated to work against new code.