Fix bug in subcategory ordering

- Fixes also one broken test