Add tests for ref in closure parameter list, closes #5239