Index: uspace/srv/net/udp/assoc.c
===================================================================
--- uspace/srv/net/udp/assoc.c	(revision a163d102718b1eaba5e08139ad98ade5e94e60ee)
+++ uspace/srv/net/udp/assoc.c	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
@@ -72,4 +72,13 @@
 }
 
+/** Finalize associations. */
+void udp_assocs_fini(void)
+{
+	assert(list_empty(&assoc_list));
+
+	amap_destroy(amap);
+	amap = NULL;
+}
+
 /** Create new association structure.
  *
@@ -174,6 +183,6 @@
 
 	assert(assoc->deleted == false);
+	assoc->deleted = true;
 	udp_assoc_delref(assoc);
-	assoc->deleted = true;
 }
 
Index: uspace/srv/net/udp/assoc.h
===================================================================
--- uspace/srv/net/udp/assoc.h	(revision a163d102718b1eaba5e08139ad98ade5e94e60ee)
+++ uspace/srv/net/udp/assoc.h	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
@@ -41,4 +41,5 @@
 
 extern errno_t udp_assocs_init(void);
+extern void udp_assocs_fini(void);
 extern udp_assoc_t *udp_assoc_new(inet_ep2_t *, udp_assoc_cb_t *, void *);
 extern void udp_assoc_delete(udp_assoc_t *);
Index: uspace/srv/net/udp/meson.build
===================================================================
--- uspace/srv/net/udp/meson.build	(revision a163d102718b1eaba5e08139ad98ade5e94e60ee)
+++ uspace/srv/net/udp/meson.build	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
@@ -28,7 +28,11 @@
 
 deps = [ 'nettl' ]
-src = files(
+
+_common_src = files(
 	'assoc.c',
 	'msg.c',
+)
+
+src = files(
 	'pdu.c',
 	'service.c',
@@ -36,2 +40,10 @@
 	'udp_inet.c',
 )
+
+test_src = files(
+	'test/assoc.c',
+	'test/main.c',
+)
+
+src = [ _common_src, src ]
+test_src = [ _common_src, test_src ]
Index: uspace/srv/net/udp/test/assoc.c
===================================================================
--- uspace/srv/net/udp/test/assoc.c	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
+++ uspace/srv/net/udp/test/assoc.c	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2019 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <errno.h>
+#include <inet/endpoint.h>
+#include <io/log.h>
+#include <pcut/pcut.h>
+
+#include "../assoc.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(assoc);
+
+static void test_recv_msg(void *, inet_ep2_t *, udp_msg_t *);
+
+static udp_assoc_cb_t test_assoc_cb = {
+	.recv_msg = test_recv_msg
+};
+
+PCUT_TEST_BEFORE
+{
+	errno_t rc;
+
+	/* We will be calling functions that perform logging */
+	rc = log_init("test-udp");
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = udp_assocs_init();
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+PCUT_TEST_AFTER
+{
+	udp_assocs_fini();
+}
+
+/** Test creating and deleting association */
+PCUT_TEST(new_delete)
+{
+	udp_assoc_t *assoc;
+	inet_ep2_t epp;
+
+	inet_ep2_init(&epp);
+	assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL);
+	PCUT_ASSERT_NOT_NULL(assoc);
+
+	udp_assoc_delete(assoc);
+}
+
+/** Test adding, removing association */
+PCUT_TEST(add_remove)
+{
+	udp_assoc_t *assoc;
+	inet_ep2_t epp;
+	errno_t rc;
+
+	inet_ep2_init(&epp);
+
+	assoc = udp_assoc_new(&epp, &test_assoc_cb, NULL);
+	PCUT_ASSERT_NOT_NULL(assoc);
+
+	rc = udp_assoc_add(assoc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	udp_assoc_remove(assoc);
+	udp_assoc_delete(assoc);
+}
+
+PCUT_TEST(addref_delref)
+{
+}
+
+PCUT_TEST(set_iplink)
+{
+}
+
+PCUT_TEST(send_recv)
+{
+}
+
+PCUT_TEST(received)
+{
+}
+
+PCUT_TEST(reset)
+{
+}
+
+static void test_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)
+{
+}
+
+PCUT_EXPORT(assoc);
Index: uspace/srv/net/udp/test/main.c
===================================================================
--- uspace/srv/net/udp/test/main.c	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
+++ uspace/srv/net/udp/test/main.c	(revision 16b0ac3f2a8983b30bbfaa3e03d69893943945c4)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <pcut/pcut.h>
+
+PCUT_INIT;
+
+PCUT_IMPORT(assoc);
+
+PCUT_MAIN();
