Enhanced tests
Some auxilliary functions added and main improved