Added test suite. Fixed found issues.