implemented RavenDB_2716 and RavenDB_2717

see http://issues.hibernatingrhinos.com/issue/RavenDB-2716 
and http://issues.hibernatingrhinos.com/issue/RavenDB-2717
for more details