Enhanced tests and fixed bugs encountered during tests