add tests, handle ordering issues around closure