Add tests for middleware expected behaviour with parenting
Implement parenting into the middleware generator function