Add tests, fix #19