Some restructure

Also add unit test framework.