Connect and disconnect in stub