Refactor logregr test code and add NULL handling test

Other authors:
    Qian, Hai <hqian@gopivotal.com>