minor fixes & test cases of gateway.go
fix conflicts