With textures, the surface and the texture(the container) share one reference count. In the case of swapchains the swapchain is the container, so a GetBackBuffer would increment the swapchain's refcount to 2. So the swapchain wouldn't be destroyed before the backbuffer was released.
I am not sure if the texture refcounting applies to swapchains as well. Does the test test refcounts? If not, it might be worth adding a test. A fix would be in dlls/d3d9, not wined3d.