implementing integrity check logic
adding integrity check tests