fix #2 and tests