Minor clean-ups and unit tests