Refactor category_handler and try to make specs happy