Integrate gtest from nupic.core

This supercedes #1299 and #1407.