Fix a bug in adapter and test for it.