Tweak databaseLock to avoid dangling references

Setting SharedCryptographyDatabase to nil would result in crashes if
some code still has a reference to the DB
rename databaseWasInitialized to WasCreated
Add database isUnlocked to clarify the flow