Category exists function with tests.