rework function wrapping, add tests