Fixes, add some tests