Fixed digest function ignoring first parameter and added tests