Added Tests and Bugfix