Added helpers for selecting, updating, and inserting records by their row id

Also moved tests into matching files, and resolved a few issues discovered on the way.