Added unit testing and little fix :)