Fix test failure on travis.

compiler: gcc, clang
build tool: autotools(gcc only), CMake(gcc and clang)

At first there were some compiler errors and some test failures on travis, now they are fixed.
@martiert 's pull request is included in this pull request because it is needed to fix compiler error on clang.

gtest, gmock support is also tested.