Test: fix test to optimize and flush in the end to try to prevent 'Delete Index failed - not acked'