[backend] clean up ugly _obsrepositories code

Also fix a bug if _obsrepositories has a priority.