fixed #6 and tests