Added some testcases for the corner-cases in question and clarified javadoc Reviewed-by: chegar, msheppar
Reviewed-by: darcy, weijun