Added unit-tests, more overloads, fixed bugs