Some bugs corrected in tests/, missing imports, etc