Fixed tests, improved parsing logic