adds tests and fixes most of them