Added unit tests. Improved docs a little.