fix some issues with the previous commits + add tests