Knocking sound in Nissan Versa on startup

Have a 2008 Nissan Versa… Nissan just replaced the engine (under warranty still fortunately) due to some issue with the dip stick… wasn’t reading the oil right or something, so a piston got fried. Anyone else experienced this? Anyway, engined got replaced… but then was leaking a lot of oil. Took the car back in, they said they damaged some membrane and had to fix that. What membrane? Now, the car makes a knocking sound when starting (driver’s side, front)… but it seems like only if the car is facing down hill, and only after sitting for a while (cold start)–we took it to the dealer again but of course it wouldn’t make the sound. They have no idea what it is but don’t think it’s a big deal. I’d like to know what the problem is. Did they break something else putting in the new engine? What’s weirder is it makes the exact same sound every once in a while when braking… but only every once in a while. Again, couldn’t get it to make the sound when on a test drive with the technician. If it matters, the driver’s side door also makes a quiet knock/bump when opening… not sure if all that’s connected.

Any insights helpful. Thanks!

KnowsNotCars