Implement category-next-id with tests.