Fixes some small bugs
Add test