Issue #507 fix

For issue #507 

- [x] Add failing test case
- [ ] Fix bug