reassignFragment fragment context fix and test issue #499

Fix and tests for #499.