Fix regression introduced in bdb064e

Also add failing test for it