Added unit test.

Implemented misc cleanups to support Linux.
Added a basic unit test.