Fixed tests
Code tweaks