Fix xunit bug

Fix an xunit bug and introduce some functional testing for the feature.