ported RavenDB-2334 fix from 2.5