reverted #1598 and added a test for it