Done some tests and minor bugfixes