Improved code coverage and code cleanup

[ci skip]
Print error message, if not in a git dir
Added test for 'ahead of upstream'
Improved code coverage of tests
Added test: diverged
Did some refactoring
Added test: up to date
Removed dead code