Add some more (currently failing) memory tests, and do some tidy-up.
Fixes to some test cases.