Refactor tests and lib

2 lines less = yes yes yes