Some tests and fixes