Added unit tests and refactored many classes to use SessionVars.