fixed bugs and made some basic tests