Modified tests and code to follow updates and more closely the book