factor leveldb init code so it can be used multiple places