Start of testing framework and bugfixes