separate database contexts and fix DB initialization logic