added tests
move digest generation to separete method