Again, he was testing BB because he realized before that physical attacks were affecting him despite him saying he was a logia, hence why he added after the attack that it was strange that it affects him despite him saying he was a logia. Note that Ace even said that he shouldn't have been affected by these kind of attacks, implying he could have affected him with other type of attacks(hakified attacks)
BB also said it had been a long while since Ace had been hit, despite living in the new world, which implies that he knew the method admirals use to nullify hakified attacks