Hamas and Fatah agree to unity government in historic deal