Added new tests. Fixed a minor bug