Tests and Fix for NH3641

https://nhibernate.jira.com/browse/NH-3641