New APIs for getting messages and message count

Introduces two APIs
* <tt>get_messages(count=1)</tt> - returns an array with max <tt>count</tt> messages
* <tt>pending()</tt> - returns the number of pending messages