Fix and add tests

Sorry about that!