Minor tweaks and fix some issues on tests