Add Test and Bugfixes