Added test case and fixed some problems with reference counting in CAFS