minor bugfixing and moving of logic in its rightful place
the test to the commit before