fix for issue 113 NPE

Patch and test for issue 113 NPE