A few minor optimizations, beginning work on PHPUnit test cases