To test last will message you need to cause the client to disconnect abnormally. If you are using a script CTRL+C may or may not work.
A better method is to stop the client loop which means that the client will not send a ping message and hence the server will see it as down and send the last will message.
Setting a very low keep alive interval of 20secs is ideal for testing.
Please rate? And use Comments to let me know more