Fixed few bugs and updated documentation.

- Some unit tests were still broken even though they were passing.
- Moved git test area outside the project tree, using a fixed temporary folder.
- Minor refactoring and code reformatting