close #15, add tests