add a number of null check to return methods. 

This is the version of #570 with tests