implement and test closure over a dynamic environment