tests and fixed bugs