Added last tests and fixed a bug