Port test.cpp to main.cpp