Fix term queries and add fail-safe in course form

* Fix 1-day delay on the first day of a term
* Gracefully handle nil terms