Add the unittest for WGT CSP handler.

Add the WGT CSP handler unittest, and fix some bugs as well.