Added test class. Fixed NPE.