Added tests, fixed --head