fixes issue #502

Well actually issue #502 was fixed with previous commits, but here is the test case to prove it.