implementing diff and apply. adding tests