Some tests, and some fixes to go along with them.