Fix unit tests with proper knowledge of object ownership