praefect: Fix flaky TestRemoveRepository_removeReplicationEvents
For some reason the test is flaky and fails with: driver: bad connection. It seems that the query runs when the test is over and connection to database is closed. But it is strange because the test should not end until the query executed. The implementation changed to omit usage of separate goroutine and sleep instead. The idea is the same - it gives a command time to iterate over and do a couple of check. The change also adds awaiting in the last loop as it burns CPU for no reason. And to prevent a live-lock the timeout was added as well.
Closes: #3833 (closed)