Test and fix for NPE. Close #12