Refactor test.cpp