Thread: fix some issues with sync_bounded_queue and added tests.