Test cases and small fixes

1. Added unit tests for analytics and some basic tests for the express server.
2.  The analytics example in `sample/basics` was based on Express 4.x. Changed it to make it runnable on 3.x
3.  If some records failed to get uploaded, add them to the queue to retry them. On `flush()`, the remote API responds back with the number of records it successfully pushed and the number that it failed. Add the number of failed ones back to the buffer. The records are processed sequentially so if 5 records are rejected, they will always be the last 5 ones.
     
In most cases, all records should be accepted. However, if the analytics service is overloaded, it might reject a few records. The JIRA issue for this recommends the caller retry the rejected records, preferably using an exponential backoff algorithm.