unit test and refactor database.py part 2

Add unit tests and refactor/fix/document issues related to the database.
(Part 2, because #619 grew too large.)

Related #484
Related #619

[sqlite and python website](http://www.pythoncentral.io/advanced-sqlite-usage-in-python/) mentions that python and SQLITE treat the ``timestamp`` SQL data type as a ``DateTime`` Python object.

The SQL statement on line 192 says to only take the date from the given timestamp value, [date documentation](https://www.sqlite.org/lang_datefunc.html).
However, SQL is kind of confusing. I changed it such that Python now get the date from the DateTime object.

In summary, the ``presentation.date`` and ``presentation.startTime or presentation.endTime`` are both of the type ``QDateTime``. ``presentation.date`` has a more specific type ``QDate`` [QDate](http://pyqt.sourceforge.net/Docs/PyQt4/qdatetime.html#date) which only contains the date part.
Both Python and SQLITE know how to convert QDateTime objects into QDate objects using a version of the ``date()`` call. In SQLITE it is just applied to a value with a timestamp like any function call in SQL, and in Python ``date()`` can be used on a QDateTime object.