Refactor C++ tests