ipa: Make test actually terminate.  Ensure termination after 30s.
diff --git a/ipa/BSC_MS_Simulation.ttcn b/ipa/BSC_MS_Simulation.ttcn
index 876db82..eab7fe9 100644
--- a/ipa/BSC_MS_Simulation.ttcn
+++ b/ipa/BSC_MS_Simulation.ttcn
@@ -26,6 +26,10 @@
 	var charstring g_bsc_num_str;
 }
 
+modulepar {
+	integer mp_num_iterations := 10;
+}
+
 function main(charstring remote_ip, PortNumber remote_port,
 		charstring local_ip, PortNumber local_port,
 		MSC_SCCP_MTP3_parameters sccp_pars,
@@ -33,11 +37,12 @@
 		SCCP_PAR_Address sccp_addr_remote, charstring id) runs on BSC_CT
 {
 	var integer i := 0;
+	timer T := 1.0;
 
 	g_sccp_addr_own := sccp_addr_own;
 	g_sccp_addr_remote := sccp_addr_remote;
 
-	/* create components */
+	/* create components for IPA/SCCP/BSS[M]AP stack */
 	vc_IPA := IPA_Emulation_CT.create(id & "-IPA");
 	vc_SCCP := SCCP_CT.create(id & "-SCCP");
 	vc_BSSMAP := BSSMAP_Emulation_CT.create(id & "-BSSMAP");
@@ -53,23 +58,23 @@
 	/* connect BSSMAP dispatcher to IPA_Emulation MGCP */
 	connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
 
+	/* start components */
 	vc_IPA.start(IPA_Emulation.main_client(remote_ip, remote_port, local_ip, local_port));
 	vc_SCCP.start(SCCPStart(sccp_pars));
 	vc_BSSMAP.start(BSSMAP_Emulation.main(BSC_MS_BssmapOps, id));
 
-	while (true) {
-		/* blocking wait for 5 seconds */
-		timer T := 5.0;
-		T.start;
-		T.timeout;
+	/* Initial delay to wait for IPA connection establishment */
+	T.start(2.0);
+	T.timeout;
 
+	for (i := 0; i < mp_num_iterations; i := i+1) {
 		f_start_BSC_MS(id & "-MS-" & int2str(i));
-		i := i + 1;
 	}
 
-	vc_IPA.done;
-	vc_BSSMAP.done;
-	vc_SCCP.done
+	/* explicitly stop all components that we started above */
+	vc_IPA.stop;
+	vc_BSSMAP.stop;
+	vc_SCCP.stop;
 }
 
 function f_start_BSC_MS(charstring id) runs on BSC_CT {
@@ -81,6 +86,9 @@
 	connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT);
 	/* start component */
 	vc_conn.start(BSC_MS_ConnectionHandler.main(g_sccp_addr_own, g_sccp_addr_remote));
+	/* blocking wait until component terminates.  If you want to start MSs in parallel,
+	 * you have to remove this statement here */
+	vc_conn.done;
 }
 
 }
diff --git a/ipa/IPA_Test.ttcn b/ipa/IPA_Test.ttcn
index c248a35..fbff84a 100644
--- a/ipa/IPA_Test.ttcn
+++ b/ipa/IPA_Test.ttcn
@@ -124,13 +124,21 @@
 }
 
 testcase TC_recv_dump() runs on test_CT {
+	var integer i;
+	timer T := 30.0;
+
 	f_init();
 
-	//var PDU_BSSAP bssap := f_gen_cl3();
-	//f_send_bssap_cc(bssap);
+	alt {
+		/* wait for BSC to stop. The idea is that the BSC components terminate first */
+		[] bsc[0].BSC.done { }
+		[] T.timeout { setverdict(fail); }
+	}
 
-	while (true) {
-		//SCCP.receive;
+	all component.stop;
+	/* terminate the MSCs */
+	for (i := 0; i < NUM_MSC; i := i+1) {
+		msc[i].MSC.stop;
 	}
 }