Added tests for date. Refactored accordingly.