Thanks for the example. It helps a lot to create a JUnit test using the wonderful FaceletTestCase base class and fix this one quickly. Just create the files, add some lines of code and that's it!.
The problem is related to FaceletContext.FACELET_CONTEXT_KEY. This key by historical reasons is assigned on the constructor of DefaultFaceletContext, but this is not good, because in some cases like ui:include, we should revert to the previous context as soon as the tag has been applied. So, this key should be put and restored on the places where a DefaultFaceletContext is created. AjaxHandler.applyAttachedObject retrieve a FaceletContext instance from this key, so if you move the button before ui:include it will work.