rewrote initDB.js so everything is wrapped in an initDB namespace (not a module because only one instance is needed at a time)

added unit tests for initDB