fixes issue #533
added spec for issue #502 - works without problems with the current code
fixes #502
Merge pull request #535 from hbrandl/issue_502_fixed

fixes issue #502