Index: uspace/app/taskbar/clock.c
===================================================================
--- uspace/app/taskbar/clock.c	(revision 3fd38b24aad2f700c8aee5299ddf03c82dd4a2c7)
+++ uspace/app/taskbar/clock.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -89,4 +89,6 @@
 	}
 
+	fibril_mutex_initialize(&clock->lock);
+	fibril_condvar_initialize(&clock->timer_done_cv);
 	fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, clock);
 
@@ -106,4 +108,23 @@
 void taskbar_clock_destroy(taskbar_clock_t *clock)
 {
+	/*
+	 * Signal to the timer that we are cleaning up. If the timer handler
+	 * misses it and sets the timer again, we will clear that active
+	 * timer and be done (and if we were even slower and the timer
+	 * fired again, it's the same situation as before.
+	 */
+	fibril_mutex_lock(&clock->lock);
+	clock->timer_cleanup = true;
+	fibril_mutex_unlock(&clock->lock);
+
+	/* If we catch the timer while it's active, there's nothing to do. */
+	if (fibril_timer_clear(clock->timer) != fts_active) {
+		/* Need to wait for timer handler to finish */
+		fibril_mutex_lock(&clock->lock);
+		while (clock->timer_done == false)
+			fibril_condvar_wait(&clock->timer_done_cv, &clock->lock);
+		fibril_mutex_unlock(&clock->lock);
+	}
+
 	fibril_timer_destroy(clock->timer);
 	ui_control_delete(clock->control);
@@ -302,6 +323,17 @@
 	taskbar_clock_t *clock = (taskbar_clock_t *) arg;
 
+	fibril_mutex_lock(&clock->lock);
 	(void) taskbar_clock_paint(clock);
-	fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer, clock);
+
+	if (!clock->timer_cleanup) {
+		fibril_timer_set(clock->timer, 1000000, taskbar_clock_timer,
+		    clock);
+	} else {
+		/* Acknowledge timer cleanup */
+		clock->timer_done = true;
+		fibril_condvar_signal(&clock->timer_done_cv);
+	}
+
+	fibril_mutex_unlock(&clock->lock);
 }
 
Index: uspace/app/taskbar/meson.build
===================================================================
--- uspace/app/taskbar/meson.build	(revision 3fd38b24aad2f700c8aee5299ddf03c82dd4a2c7)
+++ uspace/app/taskbar/meson.build	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -33,2 +33,10 @@
 	'taskbar.c',
 )
+
+test_src = files(
+	'clock.c',
+	'taskbar.c',
+	'test/clock.c',
+	'test/main.c',
+	'test/taskbar.c',
+)
Index: uspace/app/taskbar/taskbar.c
===================================================================
--- uspace/app/taskbar/taskbar.c	(revision 3fd38b24aad2f700c8aee5299ddf03c82dd4a2c7)
+++ uspace/app/taskbar/taskbar.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -92,6 +92,14 @@
 	rc = ui_get_rect(taskbar->ui, &scr_rect);
 	if (rc != EOK) {
-		printf("Error getting screen dimensions.\n");
-		goto error;
+		if (str_cmp(display_spec, UI_DISPLAY_NULL) != 0) {
+			printf("Error getting screen dimensions.\n");
+			goto error;
+		}
+
+		/* For the sake of unit tests */
+		scr_rect.p0.x = 0;
+		scr_rect.p0.y = 0;
+		scr_rect.p1.x = 100;
+		scr_rect.p1.y = 100;
 	}
 
@@ -194,4 +202,5 @@
 void taskbar_destroy(taskbar_t *taskbar)
 {
+	ui_fixed_remove(taskbar->fixed,  taskbar_clock_ctl(taskbar->clock));
 	taskbar_clock_destroy(taskbar->clock);
 	ui_window_destroy(taskbar->window);
Index: uspace/app/taskbar/test/clock.c
===================================================================
--- uspace/app/taskbar/test/clock.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
+++ uspace/app/taskbar/test/clock.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2022 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 <gfx/coord.h>
+#include <pcut/pcut.h>
+#include <ui/ui.h>
+#include <ui/window.h>
+#include "../clock.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(clock);
+
+/** Creating and destroying taskbar clock */
+PCUT_TEST(create_destroy)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** Painting taskbar clock */
+PCUT_TEST(paint)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = taskbar_clock_paint(clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** Keyboard event */
+PCUT_TEST(kbd_event)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+	kbd_event_t event;
+	ui_evclaim_t claim;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	event.type = KEY_PRESS;
+	event.key = KC_ENTER;
+	event.mods = 0;
+	claim = taskbar_clock_kbd_event(clock, &event);
+	PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** Position event */
+PCUT_TEST(pos_event)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+	pos_event_t event;
+	ui_evclaim_t claim;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	event.type = POS_PRESS;
+	event.hpos = 0;
+	event.vpos = 0;
+	claim = taskbar_clock_pos_event(clock, &event);
+	PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** taskbar_clock_ctl returns a usable UI control */
+PCUT_TEST(ctl)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+	ui_control_t *ctl;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ctl = taskbar_clock_ctl(clock);
+	PCUT_ASSERT_NOT_NULL(ctl);
+
+	rc = ui_control_paint(ctl);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** taskbar_clock_set_rect() sets internal field */
+PCUT_TEST(set_rect)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	taskbar_clock_t *clock;
+	gfx_rect_t rect;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = taskbar_clock_create(window, &clock);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+	taskbar_clock_set_rect(clock, &rect);
+
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, clock->rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, clock->rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, clock->rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, clock->rect.p1.y);
+
+	taskbar_clock_destroy(clock);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+PCUT_EXPORT(clock);
Index: uspace/app/taskbar/test/main.c
===================================================================
--- uspace/app/taskbar/test/main.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
+++ uspace/app/taskbar/test/main.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2022 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(clock);
+PCUT_IMPORT(taskbar);
+
+PCUT_MAIN();
Index: uspace/app/taskbar/test/taskbar.c
===================================================================
--- uspace/app/taskbar/test/taskbar.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
+++ uspace/app/taskbar/test/taskbar.c	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2022 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 <pcut/pcut.h>
+#include "../taskbar.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(taskbar);
+
+/* Test creating and destroying taskbar */
+PCUT_TEST(create_destroy)
+{
+	errno_t rc;
+	taskbar_t *taskbar;
+
+	rc = taskbar_create(UI_DISPLAY_NULL, &taskbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	taskbar_destroy(taskbar);
+}
+
+PCUT_EXPORT(taskbar);
Index: uspace/app/taskbar/types/clock.h
===================================================================
--- uspace/app/taskbar/types/clock.h	(revision 3fd38b24aad2f700c8aee5299ddf03c82dd4a2c7)
+++ uspace/app/taskbar/types/clock.h	(revision c77cfd848d0348e5f31cd4634ef728655b51f2aa)
@@ -55,6 +55,18 @@
 	gfx_rect_t rect;
 
+	/** Clock lock */
+	fibril_mutex_t lock;
+
 	/** Clock update timer */
 	fibril_timer_t *timer;
+
+	/** Signal to timer that we are cleaning up */
+	bool timer_cleanup;
+
+	/** Signal to maih thread that timer is done */
+	bool timer_done;
+
+	/** Timer done condition variable */
+	fibril_condvar_t timer_done_cv;
 } taskbar_clock_t;
 
