Added testing framework and tests. Some function rearranging in proc.go.