fix memleak on resetting rebind_proc
fix test