Async DB tweaks (attempt 2)

Fixed version of #572 

All bugs related to libraries.js (see https://github.com/aurimasv/zotero/commit/3f85ee73b33ff5757a0fa0ecef3983d69fb24a67 for changes)