bug fixes and first tests