Fix some bugs found while looking at test files.