Added tests. Fixed few minor issues found while writing tests.

Added tests. Fixed few minor issues found while writing tests.
Fixes #5 
Usually we keep the most resent version at the top.