fix fatal error issue and add missed test