Index: tests/CMakeLists.txt
===================================================================
--- tests/CMakeLists.txt	(revision 672)
+++ tests/CMakeLists.txt	(revision 706)
@@ -13,5 +13,5 @@
 SET(TEST_LIST
 	testsctp
-	testlist
+	testostr
 	testdict
 	testmesg
Index: tests/testdisp.c
===================================================================
--- tests/testdisp.c	(revision 662)
+++ tests/testdisp.c	(revision 706)
@@ -110,5 +110,5 @@
 	struct disp_hdl * hdl[NB_CB];
 	struct disp_when when;
-	const char * ec;
+	char * ec;
 	
 	/* First, initialize the daemon modules */
@@ -116,5 +116,6 @@
 	
 	/* Create a dummy session, we don't use it anyway */
-	CHECK( 0, fd_sess_new( &sess, "test.disp", NULL, 0 ) );
+	#define DUMMY_SID "test.disp"
+	CHECK( 0, fd_sess_new( &sess, DUMMY_SID, CONSTSTRLEN(DUMMY_SID), NULL, 0 ) );
 	
 	memset(&when, 0xff, sizeof(when)); /* check that we don't use un-initialized parts */
Index: tests/testlist.c
===================================================================
--- tests/testlist.c	(revision 662)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*********************************************************************************************************
-* Software License Agreement (BSD License)                                                               *
-* Author: Sebastien Decugis <sdecugis@nict.go.jp>							 *
-*													 *
-* Copyright (c) 2011, WIDE Project and NICT								 *
-* All rights reserved.											 *
-* 													 *
-* Redistribution and use of this software in source and binary forms, with or without modification, are  *
-* permitted provided that the following conditions are met:						 *
-* 													 *
-* * Redistributions of source code must retain the above 						 *
-*   copyright notice, this list of conditions and the 							 *
-*   following disclaimer.										 *
-*    													 *
-* * Redistributions in binary form must reproduce the above 						 *
-*   copyright notice, this list of conditions and the 							 *
-*   following disclaimer in the documentation and/or other						 *
-*   materials provided with the distribution.								 *
-* 													 *
-* * Neither the name of the WIDE Project or NICT nor the 						 *
-*   names of its contributors may be used to endorse or 						 *
-*   promote products derived from this software without 						 *
-*   specific prior written permission of WIDE Project and 						 *
-*   NICT.												 *
-* 													 *
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
-* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
-* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
-* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
-* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
-*********************************************************************************************************/
-
-#include "tests.h"
-
-#define TEST_STR "This is my test string (with extra unused data)"
-#define TEST_STRLEN 22
-
-/* Main test routine */
-int main(int argc, char *argv[])
-{
-	/* First, initialize the daemon modules */
-	INIT_FD();
-	
-	/* Check the hash function */
-	{
-		char buf[30];
-		
-		uint32_t hash = fd_hash(TEST_STR, TEST_STRLEN); /* reference value */
-		
-		/* Check that a hash of a substring / surstring is different */
-		CHECK( 1, hash != fd_hash(TEST_STR, TEST_STRLEN - 1) ? 1 : 0 );
-		CHECK( 1, hash != fd_hash(TEST_STR, TEST_STRLEN + 1) ? 1 : 0 );
-		
-		/* Check alignment of the string is not important */
-		memcpy(buf + 4, TEST_STR, TEST_STRLEN);
-		CHECK( hash, fd_hash(buf + 4, TEST_STRLEN) );
-		
-		memcpy(buf + 3, TEST_STR, TEST_STRLEN);
-		CHECK( hash, fd_hash(buf + 3, TEST_STRLEN) );
-		
-		memcpy(buf + 2, TEST_STR, TEST_STRLEN);
-		CHECK( hash, fd_hash(buf + 2, TEST_STRLEN) );
-		
-		memcpy(buf + 1, TEST_STR, TEST_STRLEN);
-		CHECK( hash, fd_hash(buf + 1, TEST_STRLEN) );
-	}
-
-	/* That's all for the tests yet */
-	PASSTEST();
-} 
-	
Index: tests/testostr.c
===================================================================
--- tests/testostr.c	(revision 706)
+++ tests/testostr.c	(revision 706)
@@ -0,0 +1,73 @@
+/*********************************************************************************************************
+* Software License Agreement (BSD License)                                                               *
+* Author: Sebastien Decugis <sdecugis@nict.go.jp>							 *
+*													 *
+* Copyright (c) 2011, WIDE Project and NICT								 *
+* All rights reserved.											 *
+* 													 *
+* Redistribution and use of this software in source and binary forms, with or without modification, are  *
+* permitted provided that the following conditions are met:						 *
+* 													 *
+* * Redistributions of source code must retain the above 						 *
+*   copyright notice, this list of conditions and the 							 *
+*   following disclaimer.										 *
+*    													 *
+* * Redistributions in binary form must reproduce the above 						 *
+*   copyright notice, this list of conditions and the 							 *
+*   following disclaimer in the documentation and/or other						 *
+*   materials provided with the distribution.								 *
+* 													 *
+* * Neither the name of the WIDE Project or NICT nor the 						 *
+*   names of its contributors may be used to endorse or 						 *
+*   promote products derived from this software without 						 *
+*   specific prior written permission of WIDE Project and 						 *
+*   NICT.												 *
+* 													 *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
+* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
+* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
+* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
+* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
+*********************************************************************************************************/
+
+#include "tests.h"
+
+#define TEST_STR (os0_t)"This is my test string (with extra unused data)"
+
+/* Main test routine */
+int main(int argc, char *argv[])
+{
+	/* First, initialize the daemon modules */
+	INIT_FD();
+	
+	/* Check the hash function */
+	{
+		uint8_t buf[30];
+		
+		uint32_t hash = fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR)); /* reference value */
+		
+		/* Check that a hash of a substring / surstring is different */
+		CHECK( 1, hash != fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR) - 1) ? 1 : 0 );
+		CHECK( 1, hash != fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR) + 1) ? 1 : 0 );
+		
+		/* Check alignment of the string is not important */
+		memcpy(buf + 4, TEST_STR, CONSTSTRLEN(TEST_STR));
+		CHECK( hash, fd_os_hash(buf + 4, CONSTSTRLEN(TEST_STR)) );
+		
+		memcpy(buf + 3, TEST_STR, CONSTSTRLEN(TEST_STR));
+		CHECK( hash, fd_os_hash(buf + 3, CONSTSTRLEN(TEST_STR)) );
+		
+		memcpy(buf + 2, TEST_STR, CONSTSTRLEN(TEST_STR));
+		CHECK( hash, fd_os_hash(buf + 2, CONSTSTRLEN(TEST_STR)) );
+		
+		memcpy(buf + 1, TEST_STR, CONSTSTRLEN(TEST_STR));
+		CHECK( hash, fd_os_hash(buf + 1, CONSTSTRLEN(TEST_STR)) );
+	}
+
+	/* That's all for the tests yet */
+	PASSTEST();
+} 
+	
Index: tests/testsctp.c
===================================================================
--- tests/testsctp.c	(revision 662)
+++ tests/testsctp.c	(revision 706)
@@ -56,10 +56,10 @@
 	PASSTEST();
 #else /* DISABLE_SCTP */
-	int sock, srvsock, clisock;
+	struct cnxctx cli, srv; /* we use only their cc_socket & cc_state */
+	int sock;
 	char buf1[]="abcdef";
 	char *buf2;
 	size_t sz;
 	struct fd_list eps = FD_LIST_INITIALIZER(eps);
-	uint32_t status = 0;
 	uint16_t str;
 	int ev;
@@ -80,4 +80,7 @@
 	}
 	
+	memset(&cli, 0, sizeof(cli));
+	memset(&srv, 0, sizeof(srv));
+	
 	/* First, initialize the daemon modules */
 	INIT_FD();
@@ -93,20 +96,20 @@
 	
 	/* Now, create the client socket */
-	CHECK( 0, fd_sctp_client( &clisock, 0, TEST_PORT, &eps ));
+	CHECK( 0, fd_sctp_client( &cli.cc_socket, 0, TEST_PORT, &eps ));
 	
 	/* Accept this connection */
-	srvsock = accept(sock, NULL, NULL);
+	srv.cc_socket = accept(sock, NULL, NULL);
 	
 	/* Send a first message */
-	CHECK( 0, fd_sctp_sendstr(srvsock, 1, (uint8_t *)buf1, sizeof(buf1), &status) );
-	CHECK( 0, status);
+	CHECK( 0, fd_sctp_sendstr(&srv, 1, (uint8_t *)buf1, sizeof(buf1) ) );
+	CHECK( 0, srv.cc_state);
 	
 	/* Receive this message */
 redo1:
-	CHECK( 0, fd_sctp_recvmeta(clisock, &str, (uint8_t **)&buf2, &sz, &ev, &status) );
+	CHECK( 0, fd_sctp_recvmeta(&cli, &str, (uint8_t **)&buf2, &sz, &ev) );
 	if (ev == FDEVP_CNX_EP_CHANGE)
 		goto redo1;
 	CHECK( FDEVP_CNX_MSG_RECV, ev);
-	CHECK( 0, status);
+	CHECK( 0, cli.cc_state);
 	CHECK( 1, str);
 	CHECK( sizeof(buf1), sz );
@@ -115,14 +118,14 @@
 	
 	/* Send in the other direction */
-	CHECK( 0, fd_sctp_sendstr(clisock, 2, (uint8_t *)buf1, sizeof(buf1), &status) );
-	CHECK( 0, status);
+	CHECK( 0, fd_sctp_sendstr(&cli, 2, (uint8_t *)buf1, sizeof(buf1)) );
+	CHECK( 0, cli.cc_state);
 	
 	/* Receive this message */
 redo2:
-	CHECK( 0, fd_sctp_recvmeta(srvsock, &str, (uint8_t **)&buf2, &sz, &ev, &status) );
+	CHECK( 0, fd_sctp_recvmeta(&srv, &str, (uint8_t **)&buf2, &sz, &ev) );
 	if (ev == FDEVP_CNX_EP_CHANGE)
 		goto redo2;
 	CHECK( FDEVP_CNX_MSG_RECV, ev);
-	CHECK( 0, status);
+	CHECK( 0, srv.cc_state);
 	CHECK( 2, str);
 	CHECK( sizeof(buf1), sz );
Index: tests/testsess.c
===================================================================
--- tests/testsess.c	(revision 662)
+++ tests/testsess.c	(revision 706)
@@ -37,16 +37,18 @@
 
 #define TEST_DIAM_ID 	"testsess.myid"
-#define TEST_OPT	"suffix"
-#define TEST_SID	TEST_DIAM_ID ";1234;5678;" TEST_OPT
+#define TEST_OPT_IN	"suffix"
+#define TEST_OPT	(os0_t)TEST_OPT_IN
+#define TEST_SID_IN	TEST_DIAM_ID ";1234;5678;" TEST_OPT_IN
+#define TEST_SID	(os0_t)TEST_SID_IN
 
 #define TEST_EYEC	0x7e57e1ec
 struct mystate {
 	int	eyec;	/* TEST_EYEC */
-	char *  sid; 	/* the session with which the data was registered */
+	os0_t   sid; 	/* the session with which the data was registered */
 	int  *  freed;	/* location where to write the freed status */
 	void *  opaque; /* if opaque was provided, this is the value we expect */
 };
 
-static void mycleanup( struct mystate * data, char * sid, void * opaque )
+static void mycleanup( struct mystate * data, os0_t sid, void * opaque )
 {
 	/* sanity */
@@ -54,5 +56,5 @@
 	CHECK( 1, data? 1 : 0 );
 	CHECK( TEST_EYEC, data->eyec );
-	CHECK( 0, strcmp(sid, data->sid) );
+	CHECK( 0, strcmp((char *)sid, (char *)data->sid) );
 	if (data->freed)
 		*(data->freed) += 1;
@@ -65,5 +67,5 @@
 }
 
-static __inline__ struct mystate * new_state(char * sid, int *freed) 
+static __inline__ struct mystate * new_state(os0_t sid, int *freed) 
 {
 	struct mystate *new;
@@ -72,5 +74,5 @@
 	memset(new, 0, sizeof(struct mystate));
 	new->eyec = TEST_EYEC;
-	new->sid = strdup(sid);
+	new->sid = os0dup(sid, strlen((char *)sid));
 	CHECK( 1, new->sid ? 1 : 0 );
 	new->freed = freed;
@@ -79,4 +81,9 @@
 
 void * g_opaque = (void *)"test";
+
+/* Avoid a lot of casts */
+#define strlen(s) strlen((char *)s)
+#define strncmp(s1,s2,l) strncmp((char *)s1, (char *)s2, l)
+#define strcmp(s1,s2) strcmp((char *)s1, (char *)s2)
 	
 
@@ -86,5 +93,6 @@
 	struct session_handler * hdl1, *hdl2;
 	struct session *sess1, *sess2, *sess3;
-	char *str1, *str2;
+	os0_t str1, str2;
+	size_t str1len, str2len;
 	int new;
 	
@@ -109,6 +117,6 @@
 	{
 		/* DiamId is provided, not opt */
-		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, NULL, 0 ) );
-		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, NULL, 0 ) );
+		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
+		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
 		#if 0
 		fd_sess_dump(0, sess1);
@@ -117,8 +125,9 @@
 		
 		/* Check both string start with the diameter Id, but are different */
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
-		CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", strlen(TEST_DIAM_ID) + 1) );
-		CHECK( 0, fd_sess_getsid(sess2, &str2) );
-		CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", strlen(TEST_DIAM_ID) + 1) );
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
+		CHECK( 1, (strlen(str1) == str1len) ? 1 : 0 );
+		CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
+		CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
+		CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
 		CHECK( 1, strcmp(str1, str2) ? 1 : 0 );
 		CHECK( 0, fd_sess_destroy( &sess1 ) );
@@ -126,18 +135,18 @@
 		
 		/* diamId and opt */
-		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, TEST_OPT, 0 ) );
-		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, TEST_OPT, strlen(TEST_OPT) - 1 ) );
-		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
-		#endif
-		
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
-		CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", strlen(TEST_DIAM_ID) + 1) );
-		CHECK( 0, strcmp(str1 + strlen(str1) - strlen(TEST_OPT) - 1, ";" TEST_OPT) );
-		
-		CHECK( 0, fd_sess_getsid(sess2, &str2) );
-		CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", strlen(TEST_DIAM_ID) + 1) );
-		CHECK( 0, strncmp(str2 + strlen(str2) - strlen(TEST_OPT), ";" TEST_OPT, strlen(TEST_OPT)) );
+		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, 0, TEST_OPT, 0 ) );
+		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), TEST_OPT, CONSTSTRLEN(TEST_OPT_IN) - 1 ) );
+		#if 0
+		fd_sess_dump(0, sess1);
+		fd_sess_dump(0, sess2);
+		#endif
+		
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
+		CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
+		CHECK( 0, strcmp(str1 + str1len - CONSTSTRLEN(TEST_OPT_IN) - 1, ";" TEST_OPT_IN) );
+		
+		CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
+		CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
+		CHECK( 0, strncmp(str2 + str2len - CONSTSTRLEN(TEST_OPT_IN), ";" TEST_OPT_IN, CONSTSTRLEN(TEST_OPT_IN)) );
 		
 		CHECK( 1, strcmp(str1, str2) ? 1 : 0 );
@@ -146,18 +155,19 @@
 		
 		/* Now, only opt is provided */
-		CHECK( 0, fd_sess_new( &sess1, NULL, TEST_SID, 0 ) );
-		CHECK( EALREADY, fd_sess_new( &sess2, NULL, TEST_SID, 0 ) );
+		CHECK( 0, fd_sess_new( &sess1, NULL, 0, TEST_SID, 0 ) );
+		CHECK( EALREADY, fd_sess_new( &sess2, NULL, 0, TEST_SID, 0 ) );
 		CHECK( sess2, sess1 );
-		CHECK( EALREADY, fd_sess_new( &sess3, NULL, TEST_SID, strlen(TEST_SID) ) );
+		CHECK( EALREADY, fd_sess_new( &sess3, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) ) );
 		CHECK( sess3, sess1 );
-		CHECK( 0, fd_sess_new( &sess2, NULL, TEST_SID, strlen(TEST_SID) - 1 ) );
-		#if 0
-		fd_sess_dump(0, sess1);
-		fd_sess_dump(0, sess2);
-		#endif
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
-		CHECK( 0, fd_sess_getsid(sess2, &str2) );
-		CHECK( 0, strncmp( str1, str2, strlen(TEST_SID) - 1 ) );
+		CHECK( 0, fd_sess_new( &sess2, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
+		#if 0
+		fd_sess_dump(0, sess1);
+		fd_sess_dump(0, sess2);
+		#endif
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
+		CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
+		CHECK( 0, strncmp( str1, str2, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
 		CHECK( 0, strcmp( str1, TEST_SID ) );
+		CHECK( 1, strcmp( str1, str2 ) ? 1 : 0 );
 		
 		CHECK( 0, fd_sess_destroy( &sess2 ) );
@@ -167,12 +177,12 @@
 	/* Test fd_sess_fromsid */
 	{
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
-		CHECK( 1, new ? 1 : 0 );
-		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess2, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
+		CHECK( 1, new ? 1 : 0 );
+		
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess2, &new ) );
 		CHECK( 0, new );
 		CHECK( sess1, sess2 );
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess3, NULL ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess3, NULL ) );
 		CHECK( sess1, sess3 );
 		
@@ -184,5 +194,5 @@
 		struct mystate *tms;
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		
@@ -190,5 +200,5 @@
 		CHECK( NULL, sess1 );
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		
@@ -199,10 +209,10 @@
 		CHECK( NULL, sess1 );
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 0, new );
 		
 		CHECK( 0, fd_sess_destroy( &sess1 ) );
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		
@@ -214,14 +224,14 @@
 		struct timespec timeout;
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		
 		CHECK( 0, clock_gettime(CLOCK_REALTIME, &timeout) );
-		CHECK( 0, fd_sess_settimeout( sess1, &timeout) );
+		CHECK( 0, fd_sess_settimeout( sess1, &timeout) ); /* expire now */
 		timeout.tv_sec = 0;
 		timeout.tv_nsec= 50000000; /* 50 ms */
 		CHECK( 0, nanosleep(&timeout, NULL) );
 		
-		CHECK( 0, fd_sess_fromsid( TEST_SID, strlen(TEST_SID), &sess1, &new ) );
+		CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		
@@ -231,7 +241,7 @@
 		
 		/* Create a second session */
-		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, NULL, 0 ) );
-		
-		/* We don't really have away to verify the expiry list is in proper order automatically here... */
+		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, 0, NULL, 0 ) );
+		
+		/* We don't really have a way to verify the expiry list is in proper order automatically here... */
 		
 		CHECK( 0, fd_sess_destroy( &sess2 ) );
@@ -248,10 +258,10 @@
 		
 		/* Create three sessions */
-		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, NULL, 0 ) );
-		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, NULL, 0 ) );
-		CHECK( 0, fd_sess_new( &sess3, TEST_DIAM_ID, NULL, 0 ) );
+		CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, 0, NULL, 0 ) );
+		CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, 0, NULL, 0 ) );
+		CHECK( 0, fd_sess_new( &sess3, TEST_DIAM_ID, 0, NULL, 0 ) );
 		
 		/* Create 2 states */
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
 		freed[0] = 0;
 		ms[0] = new_state(str1, &freed[0]);
@@ -281,15 +291,15 @@
 		/* Now create 6 states */
 		memset(&freed[0], 0, sizeof(freed));
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
 		ms[0] = new_state(str1, &freed[0]);
 		ms[1] = new_state(str1, &freed[1]);
-		CHECK( 0, fd_sess_getsid(sess2, &str1) );
+		CHECK( 0, fd_sess_getsid(sess2, &str1, &str1len) );
 		ms[2] = new_state(str1, &freed[2]);
 		ms[3] = new_state(str1, &freed[3]);
-		CHECK( 0, fd_sess_getsid(sess3, &str1) );
+		CHECK( 0, fd_sess_getsid(sess3, &str1, &str1len) );
 		ms[4] = new_state(str1, &freed[4]);
 		ms[5] = new_state(str1, &freed[5]);
 		ms[5]->opaque = g_opaque;
-		str2 = strdup(str1);
+		str2 = os0dup(str1, str1len);
 		CHECK( 1, str2 ? 1 : 0 );
 		
@@ -333,5 +343,5 @@
 		
 		/* Create again session 3, check that no data is associated to it */
-		CHECK( 0, fd_sess_fromsid( str2, strlen(str2), &sess3, &new ) );
+		CHECK( 0, fd_sess_fromsid( str2, str1len, &sess3, &new ) );
 		CHECK( 1, new ? 1 : 0 );
 		CHECK( 0, fd_sess_state_retrieve( hdl1, sess3, &tms ) );
@@ -359,8 +369,10 @@
 		/* Check the last data can still be retrieved */
 		CHECK( 0, fd_sess_state_retrieve( hdl1, sess1, &tms ) );
-		CHECK( 0, fd_sess_getsid(sess1, &str1) );
+		CHECK( 1, tms ? 1 : 0);
+		CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
 		mycleanup(tms, str1, NULL);
 	}
 	
+	/* TODO: add tests on messages referencing sessions */
 	
 	/* That's all for the tests yet */
