improved testing code