added a test to cover #509