Javascript::Promise for populating test database to ensure query calls actually works. Prevents race conditions. Further reduced the codes to ensure compactness