Fix bug in category class and use Jim's test as a test case