Added some integration tests (#2), founds a few bugs because of it.