Fix database error undefined on Chrome and count returns IDBRequest instead of result

Looks like a great idea. I won't be making any changes this weekend, but I will look into writing unit tests later.