Added some tests, some features and bug fixes.