Moves tests to separate file + adds failing test case
Fixes race condition bug