Manually merge #217
Improve tests