Finally got the database things working like I wanted
Failing test, now to implement the stuff