fixed issue #566; tests added