support externally defined sleep function (fixes #4)
add failing test for #5