Avoid UnboundLocalError in test