Fix concurrency issue in dayCount

The dayCount function was memoized, but there was no lock on the
memoization dictionary, so several of the date functions would fail when
called concurrently.  Added tests to show this, and fixed the actual
issue.