Test and fix for #534

Im trying to write an unit test for #534. Can anyone guide me in the right direction?