More tests and fixes (still in progress).