Improved testing code
Fixed merge conflicts