APY-13 : Complete the security gateway

Fixed unit testing.