Fix concurrency issue in BGP state machine test

There were occasional failures in state_machine_test. The root cause
turned out to be a concurrency issue in the test.

In production code, StateMachine::PassiveOpen is called bgp::Config
task and enqueues a EvTcpPassiveOpen event to the WorkQueue. If the
TcpSession is duplicate, the StateMachine will call DeleteSession on
the session.  Since PassiveOpen is called from bgp::Config we are
guaranteed that no other tasks will run before the call finishes.

However, the test code calls StateMachine::PassiveOpen directly from
the main thread (via BgpPeer::AcceptSession). As a consequence, it's
possible that the bgp:StateMachine task runs and calls DeleteSession
on the TcpSession before StateMachine::PassiveOpen has finished.  If
this happens, we could end up accessing the just deleted TcpSession
from StateMachine::PassiveOpen.

Tweak tests to stop the TaskScheduler before a duplicate TcpSession
is enqueued.

Change-Id: I034bf2fae242d135aade2f96c7b77a9188b56b21
Merge "Fix concurrency issue in BGP state machine test"