added tests for category hierarchy; fixed bug