Fix timing issue in test