Categories: Unit Tests

* Adds unit tests for category adaptation.

* Refactors sorting based on Niklas' comments.

Bug: 66666
Change-Id: Ica9021bbc317ac47a2f227b94ebacb216eaa9ef4
Merge "Categories: Unit Tests"