Fix #1, also add a few simple tests