LPS-47041 Fix tests

Recommit of LPS-47041 because tests were failing randomly. This is the reversion of Manuel's pull.

Thanks