added the first tests and fixed a few bugs