bz19929: handle sqlite and python returning different values for LOWER()

Now the new policy is that in SQL statements, we always use LOWER()
both things that we're comparing.  And when we store a value in
python, we always call lower() on the original value

Changed the case so we use "LOWER" instead of "lower".
Unittest fixes