Syncing with vip

Noticed a small edge case bug in code that came down from VIP, fixed that and added tests.