Fix remaining test errors and improve tests