Fix tests and other minor issues