FIX bug #832 + testcase

@stefanv hopefully, this fixes #832. Let's wait travis.