Fix bug in TablesManager where it returned two same IDs