Added in a test case for the fix, and fixed two minor problems that were made evident by fixing that test case.