Fix #13 and add test