Fixed null pointer exception and added test cases
5 files changed