Better tests, some bugfixing
remove unused variable