fix, test for issue #41

The simplest but probably performance-wise not the most optimal fix for issue #41.