Fix for #438 + tests.