Add test main.

Only tested on mac.