improve testsuite and improve code