More unit tests, minor changes, code refactoring.

- Add more unit tests.
- Refactored existing code to avoid long methods.
- Re-indented code.
- Updated the wrapper files.