Makes it work, adds a couple of tests