Fix/validations

This pull fixes: #151, #158 and #170 and adds some more tests.