added test resulting in NPE when combining count&distinct.

If you use count(distinct(proxy)) you'll face an NPE. 
I added a test demonstrating that: JPAFunctionTest.testCountDistinct as well as a test that demonstrates our current workaround. Any comment appreciated.