compiler: fix bugs in calling closures
add counter example