remove config.mode, allow algo to be a function

Fixes #10, #11 

What if method `.toString` doesn't exist in returned value? I think we should cast it using string concatenation.