Fix issues in UnitOfWork