added idempotent flag to callFunction method, fixed indenting issue, added unit test