Cleanup test code style.
Add unit tests