Fixed LearningSwitch unit tests and a couple bugs found in the code as a result.