fixes to RavenDB-1603 code + tests