pulled out unreadCount functionality for easier unit testing