added tests, did some cleaning