Advanced Tests added, refactoring