Added support for callable credential validator

This is an update for #3371, mainly by @BinaryKitten

It provides
- tests
- usage of a callback instead of a closure
- maintain BC